如何使用cakephp更新MongoDB中受影响的所有字段。我说我已经查询了开始和结束时间。我想更新特定用户的那些时间影响BETWEEN的所有字段。
<?php
$stime = $this->data["User"]["sTime"]; //$stime = "2:29 PM";
$etime = $this->data["User"]["eTime"]; //$eTime = "3:40 PM";
$user = $this->data["User"]["affected_user"];
?>
开始和结束时间内的所有字段都会受到影响。我想更新名为status的字段并将其设置为&#34; 1&#34;。感谢
答案 0 :(得分:1)
您可以使用updateAll()语句更新多个字段,例如。
<?php
// first of all convert the start time and end time in proper date format the use the statement like bellow.
$this->ModelName->updateAll(array('status' => 1), array('time >=' => $stime, 'time <' => $etime));
?>
如果要更新多个字段,则可以在同一个数组中指定类似状态。有关更多信息,请查看cakephp网站上的updateAll() documentation。