加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在CakePhp中调用unbindModel.它是如何工作的?

发布时间:2020-12-13 13:36:07 所属栏目:PHP教程 来源:网络整理
导读:unbindModel是如何在蛋糕中发生的? $this-User-unbindModel(array('hasAndBelongsToMany' = array('Friend'))); 我在函数的开头写了这个.但它仍在查询“朋友”模型.在函数中间调用了paginate().所以我认为分页器可能正在生成查询. 我在paginate之前添加了一
unbindModel是如何在蛋糕中发生的?
$this->User->unbindModel(array('hasAndBelongsToMany' => array('Friend')));

我在函数的开头写了这个.但它仍在查询“朋友”模型.在函数中间调用了paginate().所以我认为分页器可能正在生成查询.

我在paginate之前添加了一个unbindModel调用,它现在可以工作了.

$this->User->unbindModel(array('hasAndBelongsToMany' => array('Friend')));
$user = $this->paginate("User",array("User.first_name LIKE" => $user["User"]["first_name"]));

unbindModel是否取消绑定每个查询?或者在整个函数调用期间解除绑定?

From the manual:

Removing or adding associations using bind- and unbindModel() only works for the next model operation unless the second parameter has been set to false. If the second parameter has been set to false,the bind remains in place for the remainder of the request.

换句话说,在您对paginate()或find()或对模型执行任何其他操作之后,取消绑定将被反转.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读