1
內的另一種模式我有一個名爲message.php
兩款車型和user.php
CakePHP的使用模式
在message.php,我有以下計數#NO驗證的用戶的郵件的方法。
<?php
class Message extends AppModel {
...
...
...
function getInboxCount($userId) {
// Here I want to get list of ids of verified users. It means I need to use User model for this. How is it possible?
// $ids = $this->User->find('list', array('conditions' => array('User.status' => 'verified'))); Will this work?
}
}
?>
那麼如何在消息模型中使用用戶模型?
$this->User->find(...);
如果他們不相關的,你可以在任何導入任何其他型號:
這在CakePHP <2.0中是正確的,但在CakePHP> = 2.0中沒有另一種方法來做到這一點? – linkyndy 2012-02-12 16:00:54
你可以使用下面的'$ this-> loadModel('ModelName');' – gonzo 2014-01-17 21:09:09