Cakephp ClassRegistry :: init

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 causes the error is the line:

$studioAdmin = $userObj->find($conditions); 

When I talk about an error, it does not print anything and does not warn about an error, it just stops the code under it, I noticed this, because when I try to execute the echocode on it, it prints it, but when I try to make the echocode under it He doesn't print anything

What is the problem. Your help will be greatly appreciated! Thank you :)

+5
source share
2 answers

The best way to load models into components is to go through the controller and use loadModel ()

In your component configure 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);

as well as for the search term

$users = $this->Modelname->find('all', array(
   'conditions' => array(
       'User.studio_id'    => $studioID,
       'User.usergroup_id' => 5
   )
));
+2

:

$studioAdmin = $userObj->find('all', array( 'conditions' => $conditions ) );

PHP? , , ?

, , :

$conditions = array(
                "User.studio_id" => $studioID,
                "User.usergroup_id" => 5"
              );
0

All Articles