【发布时间】:2023-03-06 19:00:01
【问题描述】:
我在从 cakephp shell 获取相关模型信息时遇到问题,这是我的 shell:
class ContactShell extends Shell{
public $uses = array('Contact');
public function main(){
$contacts = $this->Contact->find('all', array(
'conditions' => array(
'Contact.is_sent' => false,
'Contact.is_bounce' => false),
'contain' => array('City' => array(
'fields' => array('City.name')))));
debug($contacts);
}
}
当我运行这个 shell 时出现错误
警告:模型“Contact”与 C:\wamp\www\togo 中的模型“City”没有关联 design\cake\libs\model\behaviors\containable.php 在第 363 行
并且结果只包含联系人模型数组。
控制器中的相同脚本显示了 City 数组
关于如何让关联在 cakephp shell 中工作的任何建议???
我也尝试过使用
$this->Contact->recursive = 1;
【问题讨论】: