Swoole\Model::set PHP Method

set() public method

更新ID为$id的记录,值为$data关联数组
public set ( $id, $data, $where = '' ) : boolean
$id
$data
$where string 指定匹配字段,默认为主键
return boolean
    public function set($id, $data, $where = '')
    {
        if (empty($where)) {
            $where = $this->primary;
        }
        return $this->db->update($id, $data, $this->table, $where);
    }

Usage Example

コード例 #1
0
ファイル: User.php プロジェクト: amydu703/quipsample
 public function toUpdateAvatar($id, $data, $where)
 {
     $result = parent::set($id, $data, $where);
     if (false === $result) {
         return ['code' => 1, 'data' => '', 'msg' => 'fail'];
     } else {
         return ['code' => 0, 'data' => '', 'msg' => 'success'];
     }
 }