Laravel: General error: 1615 Prepared statement needs to be re-prepared
It seems to work adding
'options' => [ \PDO::ATTR_EMULATE_PREPARES => true ]
Inside projectName/config/database.php
file in DB configuration. It will be like this:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'options' => [ \PDO::ATTR_EMULATE_PREPARES => true ]],
Laravel 5.1. Hope it will help!
Seems like it's a MySQL Bug that has been documented.
Edit:
Is your model using 'id' as the primary key? I like to set the primary key explicitly in the model even if it is.
protected $primaryKey = 'id'; // If different than id, definitely need to set the column here
You can also try commenting out the hasMany()
functions and trying again. Sometimes Laravel can do weird things on eagerLoad, especially if there are A LOT of records that it is trying to map to.