我在我的控制器里叫这个:
public function index() {
$this->Product->recursive = 2;
$this->Product->unbindModel(array('hasMany' => array('Productproperty')), true);
$this->Product->Ranking->unbindModel(array('belongsTo' => array('Product', 'Contacts')), true);
$this->Product->Ranking->bindModel(array('belongsTo' => array('Customer' => array('foreignKey' => false))), true);
$this->set('products', $this->Paginator->paginate());
}我得到我想要的所有日期,语句在调试中是正确的。数据输出对我来说是正确和完美的。
但是我在屏幕上得到了一条错误消息:
为foreach() CORE\Cake\Model\Datasource\DboSource.php提供的无效参数,第1695行
我想知道为什么dboSource会参与其中?有什么不对吗?
发布于 2014-06-13 23:18:00
foreach ($conditions as $key => $condition) { ... }在我看来,您在分页查询中完全丢失了“条件”。你试过在里面放什么东西吗?也许在取消绑定之后,默认结构发生了变化,不知何故丢失了?我想可能是CakePHP的错误。
发布于 2014-06-17 16:39:48
在重新考虑了结构和许多小时的尝试和错误之后. :-)这确实是我造成的语法错误。这是我的解决办法:
public function index() {
$this->set('title_for_layout','Statistiken');
$this->Product->recursive = 3;
$this->Product->unbindModel(array('hasMany' => array('Productproperty')), true);
$this->Product->Ranking->unbindModel(array('belongsTo' => array('Product', 'Contacts')), true);
$this->Product->Ranking->Contact->unbindModel(array('hasMany' => array('Ranking')), true);
$this->set('products', $this->Paginator->paginate());
}https://stackoverflow.com/questions/24209176
复制相似问题