Tuesday, April 29, 2014

How to retrieve data from anther table in one model

I wanna retrieve data from anther table in one model.
case is like this:
in a model,eg:StaticTable,I set $useTable as false;
so in one function,I just wanna get data from some table.how can I manage
it?
Here is my code,but it doese't work.
part of the code in app/Model/StaticTable.php:
class StaticTable extends Model{
public $useTable = false;
protected $_tableName = '';
public function get_some_data(){
$this->_tableName = 'tb_server_info';
$serverInfo = $this->find('all', array(
'conditions' => array('status'=>1),
'order'=>array('created_date'=>'asc')
));
$this->_tableName = 'tb_platform_info';
$platformInfo= $this->find('all', array(
'conditions' => array('status'=>1),
'order'=>array('created_date'=>'asc')
));
return
array('server_info'=>$serverInfo.'platform_info'=>$platformInfo);
}
}



--
View this message in context: http://cakephp.1045679.n5.nabble.com/How-to-retrieve-data-from-anther-table-in-one-model-tp5718071.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: