我在我的应用程序中使用 mysql 5.7、laravel5.2 和 php 5.6.17..
我创建了一个迁移表
public function up()
{
Schema::create('admin_login_history', function (Blueprint $table) {
$table->increments('id');
$table->string('url');
$table->json('client_details');
$table->integer('user_id')->nullable();
$table->timestamps();
});
}
我为它创建了一个模型..
class AdminLoginHistory extends Model
{
protected $table = 'admin_login_history';
protected $fillable = ['file_path', 'url', 'user_id', 'client_details'];
protected $casts = ['client_details' => 'json'];
}
我正在插入一个 client_details 的数据数组,该数组在我的模型中转换为 json。
现在从表中检索数据时出现错误
$loginhistory = AdminLoginHistory::where('user_id', $id)->orderBy('created_at', 'desc')->take(3)->get();
错误:
File Path: /home/storage/elivio/InvizoAdmin/vendor/laravel/framework/src/Illuminate/Database/Connection.php
Error Code:HY000, Line Number:669
Message:SQLSTATE[HY000]: General error: 2036 (SQL: select * from `admin_login_history` where `user_id` = 1 order by `created_at` desc limit 3)