Home  >  Article  >  php教程  >  add()插入成功,但是返回false

add()插入成功,但是返回false

WBOY
WBOYOriginal
2016-06-07 11:42:192020browse

谁遇到过add()插入成功,但是返回false?大神帮我看看代码
$review = M("review");
if ($review->create()) {
$review->addtime=time();
$review->uid='2';
$review->username='zhangsan';
$review->vid=$_POST['vid']; //(这里如果不加上也添加不进去)
$review->content=$_POST['content'];//(这里如果不加上也添加不进去)

if ($id = $review->add()) {//(这里返回的$id是false,但是已经插入成功)

$vo = $review->where("vid=1")->field('username','content','addtime')->order('id desc')->find($id);
$this->ajaxReturn($vo, 'ok', 1);
} else {
$this->error($review->getError());
}
} else {
$this->error($review->getError());

//,使用下面的方法也一样的效果(add()插入成功,返回false)
$data['addtime']=time();
$data['uid']='2';
$data['username']='zhangsan';
$data['vid']=$_POST['vid'];
$data['content']=$_POST['content'];
$id = $review->add($data);
dump($id);exit;

AD:真正免费,域名+虚机+企业邮箱=0元

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