#1 jiayan41
如何实现浏览文章后数据库该文章浏览数自动加一 ?我使用smarty模板
2010-05-18 09:06:50
2010-05-18 09:06:50
2010-05-18 09:31:14
2010-05-18 10:56:37
我这样写貌似不行啊
$id = $this->spArgs("id")
$count = spClass("lib_contents");
$upconditions = array("id"=>$id);
$upcount = array('count' => count+1);
$count->update($upconditions, $upcount); // 更新记录
2010-05-18 16:31:55
2010-05-18 16:47:49
$count = spClass("lib_contents");dump结果:UPDATE j_contents SET count = '1' WHERE id = '104'
$upconditions = array("id"=>$id);
$count->updateField($upconditions, 'count', 1); // 更新count字段加 1
dump($count);
public function updateField($conditions, $field, $value)
{
return $this->update($conditions, array($field=>$value));
}
$count->updateField($upconditions, 'count', 'count'+1); // 更新count字段加 1
dump($count);
2010-05-18 16:59:57
2010-05-18 17:47:10
2010-05-18 18:28:14
2010-05-18 18:39:14
//实现产品浏览次数加一功能实现了,谢谢azwl
$count = spClass("lib_contents");
$upconditions = array("id"=>$id);
$upcount = 'count';
$count->incrField($upconditions, $upcount, 1);
2010-05-18 19:57:58