蔭全光照MySQL的5.7,在我的申請laravel5.2和PHP 5.6.17 ..在MySQL 5.7從JSON列類型檢索JSON數據時使用laravel 5.2得到錯誤
我創建遷移表
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'];
}
蔭插入其換算爲JSON在我的模型client_details的數據的數組。
現在檢索時從表中IAM的數據得到錯誤
$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)