2016-03-22 8 views
0

IamはusinのMySQL 5.7、laravel5.2とPHP 5.6.17を取得laravel 5.2を使用してMySQL 5.7でのJSON列タイプから..私のアプリケーションでエラー

をJSONデータを取得するとき、私は

移行テーブルを作成します
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(); 
     }); 
    } 

私は私のモデルにJSONに変換されclient_detailsのデータの配列を挿入する。..

class AdminLoginHistory extends Model 
{ 

    protected $table = 'admin_login_history'; 

    protected $fillable = ['file_path', 'url', 'user_id', 'client_details']; 

    protected $casts = ['client_details' => 'json']; 
} 

はIAMをそのためのモデルを作成しました。今

$loginhistory = AdminLoginHistory::where('user_id', $id)->orderBy('created_at', 'desc')->take(3)->get(); 

エラーテーブルからIAM取得中にエラーがデータを取得する:

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) 

答えて

0

これはthis postのようになりますが。 JSONデータはMySQLではまだ相対的に新しいので、少し前に物事が堅調に推移すると思う。

0

"MySQL 5.7.8以降、MySQLはネイティブJSONデータ型をサポートしています..."したがって、正しいバージョンのmysql(5.7.8またはそれ以上)があるかどうかを確認してください。

Mysql 5.7.8 JSON data type, doc