easy-swoole / orm

31 stars 27 forks source link

orm的update方法不能使用 #146

Closed Marber-seven closed 4 years ago

Marber-seven commented 4 years ago

easyswoole框架版本号、orm组件版本号 [Version]

easyswoole version:3.3.7 orm version:1.4.11 swoole version:4.4.16

问题描述和截图 [Question]

查询和更新不能同时使用

排查情况和最小复现脚本 [Tests and Recurrence]

$adminModel = new Admin();//实例化模型 $admin = $adminModel->get([ "account" => "admin" ])->toArray();

下面的执行错误

$adminModel->update([ "login_time" => time(), "login_ip" => "127.0.0.1" ], [ "id" => 1 ]);

报错信息

[2020-06-16 09:39:06][debug][warning]:[array_diff_assoc(): Argument #2 is not an array at file:/www/wwwroot/???/vendor/easyswoole/orm/src/AbstractModel.php line:647] [2020-06-16 09:39:06][debug][warning]:[array_merge(): Argument #1 is not an array at file:/www/wwwroot/???/vendor/easyswoole/orm/src/AbstractModel.php line:648]

Player626 commented 4 years ago

我当前环境配置到与你一致,并未出现报错信息。

public function getOne()
{
    $param = $this->request()->getRequestParam();
    $model = new TestModel();

    $info = $model->get(['id' => $param['id']])->toArray();

    $model->update(['text' => 1],['id' => $param['id']]);

    if ($info) {
        $this->writeJson(Status::CODE_OK, $info, "获取数据成功.");
    } else {
        $this->writeJson(Status::CODE_BAD_REQUEST, [], '数据不存在');
    }
}

请检查下你的orm版本代码是否成功更新

Player626 commented 4 years ago

数据库当前数据: 当前请求: 执行后结果: