Welcome, Guest
Username: Password: Remember me

TOPIC: [FAQ] Reusing a table in more than one project

[FAQ] Reusing a table in more than one project 13 Feb 2012 01:31 #1249

  • antzog
  • antzog's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Karma: 0
Hi there,

I have been looking at ways to convert a bunch of 1.5 components to work in J2.5 and Cook seems to be perfect for this so am very excited to have found it.

Our site uses five main tables that contain info that is used in nearly all of our ten components. There are also tables that are specific to certain components. I have been playing with Cook and I can see how to create tables within projects but not how to use a table in more than one project. I would like to keep the components seperate rather than mash them together into one large project.

Could you please advise me whether there is a way in which tables can be used in more than one project/component?

I have had a hunt through the forum (very interesting reading) and cannot see anything on this topic but I may have missed it...

I look forward to the comments of anyone who can offer advice on this as I'm really excited about developing further with Cook.

Thanks
Beaker
Last Edit: 13 Feb 2012 14:44 by admin.
The administrator has disabled public write access.

Reusing a table in more than one project 13 Feb 2012 11:57 #1257

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Cook doesn't do it for you but coding it is very simple.


TODO :

Where you want in (almost) anywhere of Joomla! :
load the model files concerned by your request.
require_once(....);

create a new model instance :

$model_xxxx =& JModel::getInstance('xxxx', 'MycomponentModel');

//FACULTATIVE - Use the model as you want
$model_xxxx->addJoin(...);
$model_xxxx->addSelect(...);
$model_xxxx->addGroupBy(...);
$model_xxxx->addOrder(...);
$model_xxxx->active('predefined', '...');
// END

$items = $model_xxxx->getData();
Coding is now a piece of cake
Last Edit: 13 Feb 2012 11:58 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: twev

Re: Reusing a table in more than one project 13 Feb 2012 14:19 #1269

  • antzog
  • antzog's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Karma: 0
Thanks for your (very) quick reply. I shall have a go and let you know whether it works for me. My MVC coding skills are limited (hence why I am using Cook!) but fingers crossed I can work it out.

Cheers
The administrator has disabled public write access.
Time to create page: 0.104 seconds

Get Started