I'm working on CakePHP 3.2
My application was working fine earlier but from last few days giving error as
Error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
SQL Query
SELECT Categories.id AS
Categories__id, Categories.title ASCategories__title, Categories.description ASCategories__description, Categories.icon ASCategories__icon, Categories.c_status ASCategories__c_status, Categories.created ASCategories__created, Categories.modified ASCategories__modifiedFROM categories Categories WHERE Categories.c_status = 1
and a suggestion
If you are using SQL keywords as table column names, you can enable identifier quoting for your database connection in config/app.php.
I tried with enabling identifier in app.php then also same error.
Source code for generated query
$menu_categories = $this->Categories->find('all', [
'conditions' => [
'Categories.c_status' => 1,
],
'contain' => [
'Subcategories.ProductTypes' => [
'conditions' => [
'ProductTypes.status' => 1,
],
],
'CategoryBanners' => [
'conditions' => [
'CategoryBanners.status' => 1,
],
],
],
]);
$this->set('menu_categories', $menu_categories);
What could be the cause for the error ?
I had this error, and it turned out to be an issue with the "max_allowed_packet" setting for the database. I increased mine from the default up to 16MB, and it resolved my issue. Something to check on and experiment with if you or anybody else is having this error.