execute和query

ThinkPHP,execute和query

巧了我就是萌 提交于 2021-01-13 21:14:32
// +--------------------------------------------------------------- // | update o2o_users set gold = (gold + '-1') where user_id = '245' // +--------------------------------------------------------------- public function updateCount($id,$col,$num = 1){ // 245, gold, 1 $id = (int)$id; return $this->execute(" update ".$this->getTableName()." set {$col} = ({$col} + '{$num}') where ".$this->pk." = '{$id}' "); //execute 常用作update和insert,返回影响的行数 //query常用作select,放回影响的数集,array() //update o2o_users set gold = (gold + '-1') where user_id = '245' } 来源: oschina 链接: https://my.oschina.net/u/2519486/blog