Suppose I have Model1 and it is not associated to Model2 by hasOne or any other relation. How can I access info from Model2?
I tried the following way:
Model/Model1.php
class Model1 extends AppModel{
public function getInfo(){
App::uses('Model2','Model');
$mod2_info=$this->Model2->find('all');
return $mod2_info;
}
}//end of class
Controllers/Model1sController.php
class Model1sController extends AppController{
public function index(){
set('info', $this->Model1->find('all'));
}
}//end of class
View/Model1/index.ctp
<?php var_dump($info); ?>
Browser Output:
Fatal error:Call to a member function find() on a non-object in Model/Model1.php