I have this code:
$userObj = ClassRegistry::init('User');
$userObj->contain();
$conditions = "User.studio_id = '".$studioID."' AND User.usergroup_id = 5";
$studioAdmin = $userObj->find($conditions);
The one that is causing the error is this line:
$studioAdmin = $userObj->find($conditions);
When I say error, it does not print anything or any warning of error, it just stops the code below it, I noticed that one because when I try to echo
a code above it, it prints it, but when I try to echo
a code below it, it does not print anything,
What is the problem here. Your help will be greatly appreciated! Thanks! :)
The better practice way of loading models in components is to go via the controller, and use loadModel()
In your component, set up the initialize()
function initialize($controller, $settings) {
$this->Controller =& $controller;
}
Then in your component function, use loadModel to load the model
$this->Controller->loadModel('Modelname');
$this->Modelname->save($data);
and also for find condition
$users = $this->Modelname->find('all', array(
'conditions' => array(
'User.studio_id' => $studioID,
'User.usergroup_id' => 5
)
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With