早睡早起,方能养生
Sleep early rise early, way to keep healthy

Argument 1 passed to think\db\Query::getFieldType() must be of the type string, int given, called in xxxxxxxx

super
2021-10-14 15:29
views 10660

今天thinkphp6.0又出'bug'啦!

 

// 申请
public function apply($user_id, $icon_id)
{
    // 查询申请记录
    $log = $this
        ->where([
            ['user_id', '=', $user_id],
            ['icon_id', '=', $icon_id]
        ])
        ->field(['id'])
        ->find();
    if ($log) {
        $result = $this
            ->where($this->pk, $log['id'])
            ->inc('num')
            ->update([
                'apply_time' => time()
            ]);
        return ($result !== false) ? true : false;
    } else {
        $result = $this
            ->insertGetId([
                ['user_id', '=', $user_id],
                ['icon_id', '=', $icon_id],
                ['time', '=', time()],
                ['num', '=', 1]
            ]);
        return $result ? true : false;
    }
}

 

最后发现还是自己的问题, 看上面代码的 else 模块, 添加数据时,其实应该是一维数组, 而我写错成了二维数组(因为复制了上面的数组), 所以报错了。

 

如果你也报错了的话, 记得再仔细审查一下代码!!!!!!



分享
0 条讨论
top