Post by starman » Thu Apr 14, 2011 7:36 pm

Hi,
Installed OC. Looks great.
Can I add a table to the database, and if so, how do I refer to it in the page coding, since the existing version of my client's page uses a database and connection function that I created earlier.
Obviously I need to scrub that - so do I just replace 'my' php-include file name with the OC php-include file name (whatever it is)?
Basically, what are the steps I need to take to make his site use only the OC database rather than the one I am currently using? A feature of the home page is that it displays the latest updates (for instance "Diversion due to large hole in Ketts Hill") which are retrieved from a database. I have provided my client with a quick form where he can enter these details but obviously if this form is now connecting to the OC database I need to know how to amend the connection details.
Many thanks!

Newbie

Posts

Joined
Tue Apr 05, 2011 12:08 am

Post by jcsmithy » Thu Apr 14, 2011 9:30 pm

Yes, you can add your own table to the database. Just don't touch any of the existing table's else you will cause problems.

To keep things simple, you can just make the call straight from the tpl file with the following code.

Code: Select all

<?php $results = $this->db->query("SELECT name FROM new_table"); 

foreach($results->rows as $result) { 
   echo $result['name'];
} ?>

Active Member

Posts

Joined
Fri Oct 01, 2010 9:54 pm

Post by starman » Fri Apr 15, 2011 1:02 am

Thanks for that. One prob... what's a tpl file? Is this "dot-tpl, i.e., an actual file type? I'm brand new to this, and aren't quite au fait with the terminology yet! cheers.

Newbie

Posts

Joined
Tue Apr 05, 2011 12:08 am

Post by phpuk » Fri Apr 15, 2011 1:08 am

Open cart uses mvc architecture so all of the template files are in view. The V part.

Global Moderator

Posts

Joined
Wed Mar 25, 2009 10:57 am

Post by starman » Sat Apr 16, 2011 9:00 am

Ah, OK. So tpl is a template file. MVC? More mysterious acronyms! Googled, and take it that's Model-View-Controller. That's certainly useful for the next pub quiz, but I'm in the dark as to what it actually is! Probably a trip to the local library to request "the book" is on the cards.

Newbie

Posts

Joined
Tue Apr 05, 2011 12:08 am

Post by jcsmithy » Tue Apr 19, 2011 3:49 pm

Its just a framework that seperates the different erm... functions

Model - All the database calls
View - HTML & theming files
Controller - Place where the Model and View are Linked together

Each is seperated out for an easier logic

Look here for more information
http://forum.opencart.com/viewtopic.php?f=20&t=4113

Active Member

Posts

Joined
Fri Oct 01, 2010 9:54 pm
Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 219 guests