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