thinkphp中数据更新时的现象
Jun 23, 2016 pm 02:02 PM $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));

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
