Hello,
I'm still a bit stuck in the MVC architecture. I've two models A and B
which are not logically linked (let's imagine model A is a racing car
and model B is a spectator of a race), so I haven't built any
association between them. How can I use both models in a function in
model A, I mean what is the best way to load B in A ? I4ve in mind two
solution : first one is loading models in controller, retrieving data
and passing them to function, but it's not controllers thin models
fat. Second one is classregistry loading inside of the model, but
might it be time consuming?
Example :
-------------FIRST example -------------------
AController
{
function AAA($a_id,$b_id)
{
$a=$this->a->find(..conditions => ... a_id....)
$this->loadModel('b');
$b=$this->b->find((..conditions => ... b_id...);
$result=$this->a->funA($a,$b)
}
}
AModel
{
function funA($a,$b)
{Logic, whole stuff, data treatment}
}
------------SECOND example -----------------------
AController
{
function AAA($a_id,$b_id)
{
$result=$this->a->funA($a_id,$b_id)
}
}
AModel
{
function funA($a_id,$b_id)
{
$a=$this->find(..conditions => ... a_id....)
$b=ClassRegistry::init(a)->find(..conditions => ... b_id....)
}
}
Thank you a lot!
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php