christophrumpel's avatar

MySql error when working with a mysql view

Hey,

I've developed a web app on Homestead and everything worked just fine. Now on the production server I get this error

"General error: 1615 Prepared statement needs to be re-prepared (SQL: select score from highscore where user_id = 1)”

It seems like this is a Mysql Bug and has something to do with too many queries (http://bugs.mysql.com/bug.php?id=42041) but I am not sure. If I comment this query above out, I get the same error for the next query. I am querying a lot of user and game history data for this request. (some data from MySqls views too)

Has anyone an idea?

PHP 5.5.18 MySql 5.6.17

0 likes
8 replies
christophrumpel's avatar

Update:

I just noticed that this error only occurs when I try to get data from the Mysql view. Both of the queries do not work.

return DB::table('highscore')->where('user_id', 1)->get();
return Highscore::where('user_id', 1)->get(array('score'))[0]['score'];
slovenianGooner's avatar

Yup, I've encountered that issue aswell lately. After some time, I think I've found that it's a MySQL bug rather than Laravel specific.

christophrumpel's avatar
Level 5

My provider increased mysql table_definition_cache and now it is working again!

1 like
kamaroly's avatar

in your config/database.php add below option in your mysql config. this is desabled by laravel by default

'options'   => [
                        \PDO::ATTR_EMULATE_PREPARES => true
                    ],
5 likes
ngseklong's avatar

kamaroly method works amazingly. I don't really want to contact my provider just for that, so thanks a lot!

amitvik's avatar

Both the solutions didn't work for me

sembrador's avatar

kamaroly answer works for me too.

Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04, PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )

Please or to participate in this conversation.