0
我通過動態更改hasAndBelongsToMany條件來選擇Blog條目,它不再適用於CakePHP 1.3中的我。 奇怪的問題,導致它與1.2工作正常,在模型中,我通過將條件與靜態ID進行測試來查看發生了什麼,(Tag.name => 'libros')
。但它通過hasAndBelongsToMany條件。帶給我任何結果。通過更改模型中的條件,hasAndBelongsToMany問題
var $hasAndBelongsToMany = array('Tag' =>
array('className' => 'Tag',
'joinTable' => 'blogs_tags',
'foreignKey' => 'blog_id',
'associationForeignKey'=> 'tag_id',
'conditions' => '',
'order' => '',
'limit' => '',
'unique' => true,
'finderSql' => '',
'deleteQuery'=> ''
)
控制器
$this->Blog->bindModel(array(
'hasAndBelongsToMany' => array(
'Tag' => array('conditions'=>array('Tag.name'=>'libros'))
)));
$this->Blog->find('all');
現在我沒有MySQL錯誤了,但我也有其它的記錄與他人的結果。奇怪的。
呀它的作品!我非常感謝你,這非常有用! – user784083