How to get rid of MySQL error 'Prepared statement needs to be re-prepared'
This is a possibility: MySQL bug #42041
They suggest upping the value of table_definition_cache
.
You can read about statement caching in the MySQL docs.
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!
Edit:
I'm currently on Laravel 8 and this solution is still working.
How to SELECT from a view in SQL? (General error: 1615 Prepared statement needs to be re-prepared)
The solution in this instance was as follows:
Emulation of prepared statements needs to be enabled.
In the connection file, the following line
PDO::ATTR_EMULATE_PREPARES => false,
needs to be changed like so:
PDO::ATTR_EMULATE_PREPARES => true,
In other instances it appears the solution may be to increase the table_definitition_cache
Related Topics
Php, Display Image with Header()
How to Replace (Monkeypatch) PHP Functions
Deleting All Files from a Folder Using PHP
Performance of Try-Catch in PHP
How to Logout from a Session in PHP
Why Are "Echo" Short Tags Permanently Enabled as of PHP 5.4
Is There Way to Keep Delimiter While Using PHP Explode or Other Similar Functions
Do Login Forms Need Tokens Against Csrf Attacks
How to Dynamically Write a PHP Object Property Name
PHP Expects T_Paamayim_Nekudotayim
How to Use PHP to Check If a Directory Is Empty
Recursively Remove Empty Elements and Subarrays from a Multi-Dimensional Array