TP5.0的update方法问题

浏览:6606 发布日期:2018/04/26 分类:技术分享
update方法返回的不是修改数据的条数,返回的确是对象,那么我该如何判断他是否修改成功?    /**
     * 更新数据
     * @access public
     * @param array      $data  数据数组
     * @param array      $where 更新条件
     * @param array|true $field 允许字段
     * @return $this
     */
    public static function update($data = [], $where = [], $field = null)
    {
        $model = new static();
        if (!empty($field)) {
            $model->allowField($field);
        }
        $result = $model->isUpdate(true)->save($data, $where);
        return $model;
    }
我是这么去写的        $companyModel = new \app\basic\model\Company();
        $data = array(
            'company_id' => 11,
            'company_name' => 'tp5测ds试',
        );
        $result = $companyModel->update($data);
        var_dump($result);die;
最佳答案
评论( 相关
后面还有条评论,点击查看>>