Home >Backend Development >PHP Tutorial >thinkphp数据库问题,大家看到帮帮忙,还在加班处理这个问题,谢谢了

thinkphp数据库问题,大家看到帮帮忙,还在加班处理这个问题,谢谢了

WBOY
WBOYOriginal
2016-06-20 12:26:26768browse

需求:在thinkPHP中,如何用代码去判断当ispass为1时,向数据库中插入successtime字段的时间戳。

这是数据库表:

我的代码是这样写的,然后是错误的,大家帮帮忙,谢谢了。
$rob=M('rob');
if($rob->where(array('ispass'=>1))){
$time=time();
$data['successtime']=$time;
$rob_success=$rob->add($data);
if($rob_success){
$this->success('插入成功!');
}
}


回复讨论(解决方案)

$rob=M('rob');$data = array('successtime'=>time());if($rob->where(array('ispass'=>1))->save($data) !== FALSE){    $this->success('插入时间成功');}else{    $this->error('插入失败!');}

$model->where("ispass=1")->setField("successtime",time());

$model->where("ispass=1")->setField("successtime",$_SERVER['REQUEST_TIME']);

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