首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cakephp 2.5使用bind / unbind时出错

Cakephp 2.5使用bind / unbind时出错
EN

Stack Overflow用户
提问于 2014-06-13 15:39:54
回答 2查看 486关注 0票数 0

我在我的控制器里叫这个:

代码语言:javascript
复制
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会参与其中?有什么不对吗?

EN

回答 2

Stack Overflow用户

发布于 2014-06-13 23:18:00

来自DBOSource 1695行

代码语言:javascript
复制
foreach ($conditions as $key => $condition) { ... }

在我看来,您在分页查询中完全丢失了“条件”。你试过在里面放什么东西吗?也许在取消绑定之后,默认结构发生了变化,不知何故丢失了?我想可能是CakePHP的错误。

票数 0
EN

Stack Overflow用户

发布于 2014-06-17 16:39:48

在重新考虑了结构和许多小时的尝试和错误之后. :-)这确实是我造成的语法错误。这是我的解决办法:

代码语言:javascript
复制
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());
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24209176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档