Home  >  Article  >  Backend Development  >  thinkphp中数据更新时的现象

thinkphp中数据更新时的现象

WBOY
WBOYOriginal
2016-06-23 14:02:54923browse

  $result = $User->where("u_id=".$user_id)->setField('img_url',$url);
  if($result !== false){
        echo '数据更新成功!';
    }else{
        echo '没更新任何数据!';
    }

当$url的值不变,多次提交时,
第一次成功,后面的都是false。

这是是什么机制?有知道的童学解释一下啊。



回复讨论(解决方案)

看手册上面说,你还需要传递一个条件就可以保存成功了,前提是u_id为主键。
修改代码如下:  $result = $User->where("u_id=".$user_id)->setField(array('u_id','img_url'),array($user_id,$url));

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn