There are times that we want to link-up the model, but not the "hard way" example: hasOne, hasMany, belongsTo etc.
When you are in such situation the code below might be able to help you.
We can actually use the model function by using ClassRegistry class.
Below are the example:class ThisModel extends AppModel {
var $name = "ThisModel";
function somename($id){
//note that "ThatModel" does not belongs to "ThisModel"
$rows = ClassRegistry::init("ThatModel")->findById($id);
}
}
Wednesday, December 23, 2009
CakePHP - Load Model within Model
Subscribe to:
Post Comments (Atom)
2 comments:
Hey...just dropping by to say hi!
HAppy New Year to ya! Hope you have a fruitful year ahead!
Cheers!
Hi!, happy new year :)
Post a Comment