2016-03-22 10 views
0

Iam MySQL 5.7, laravel5.2 und PHP 5.6.17 in meiner Anwendung usin ..wenn json Daten aus dem json Spaltentyp in MySQL 5.7 mit Laravel 5.2 Abrufen Fehler bekommen

Ich habe eine Migrationstabelle

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(); 
     }); 
    } 

habe ich ein Modell für sie ..

class AdminLoginHistory extends Model 
{ 

    protected $table = 'admin_login_history'; 

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

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

Iam ein Array von Daten von client_details eingefügt, der json in meinem Modell umgewandelt wird.

jetzt beim Abrufen der Daten aus der Tabelle iam Fehler bekommen

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

Fehler:

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) 

Antwort

0

Dies könnte zu this post ähnlich sein. JSON-Daten sind in MySQL immer noch relativ neu, daher denke ich, dass es etwas dauern wird, bis die Dinge solide sind.

Verwandte Themen