Single Component, multiple tables. How?

Contact the Development Working Group here: http://groups.google.com/group/joomla-dev-general

This forum is now closed and archived.
Locked
reashlin
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Mon Dec 03, 2007 11:23 am

Single Component, multiple tables. How?

Post by reashlin » Mon Dec 10, 2007 11:30 am

Hey,

I am relatively new to Joomla! so this mya seem pretty stupid but I am working on a new component that requires multiple tables in the database to work properly.

I know about extending JTable in a new class but I can't work out how to get this to talk to mulitple tables.

Once I've got this working i'm then not sure how I am able to work with the database, ie. how do I add new records to multiple tables at once.

I can provide code examples if this may help.

macuserfr
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Sun Nov 11, 2007 10:51 am

Re: Single Component, multiple tables. How?

Post by macuserfr » Thu Jun 04, 2009 3:22 pm

I'm on the same situation. Making a component in joomla to handle a simple prices database. I have 4 tables. I've read the Hello component tutorial (thanks for that doc!) that makes my component work for 1 table, but I'm lost in the MVC pattern to add another 3 tables. Don't know what to add and how to make the connections. I would be very thankful if someone can explain this.

User avatar
MrS.Siam
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 158
Joined: Mon Aug 06, 2007 2:18 am
Location: Nonthaburi Thailand
Contact:

Re: Single Component, multiple tables. How?

Post by MrS.Siam » Wed Oct 21, 2009 6:26 pm

I just use like this

class Schedule extends ....
{
var $id;
var $property1;
var $property2;
var $resources = null; //I create object of here.
var $reservations = null; // I create object of reservation data here!

.......
function _getResources()
{
//load all resources for this schedule
$this->resources = new Resource($this->id);
}
}

class Resource extends ...
{

}

class Reservation extends ...
{

}

Or you can use Iterator pattern to add details to master record.
Help to build Joomla! community
http://www.joomlant.com


Locked

Return to “Development”