0

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 AS Categories__title, Categories.description AS Categories__description, Categories.icon AS Categories__icon, Categories.c_status AS Categories__c_status, Categories.created AS Categories__created, Categories.modified AS Categories__modified FROM 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 ?

Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
  • 1
    This error is coming straight from MySQL, have you Googled it to see common causes and solutions? – Greg Schmidt Oct 18 '16 at 03:34
  • running query in phpmyadmin is working fine – Anuj TBE Oct 18 '16 at 15:47
  • Even so, Googling the error message will find you some diagnostics that you can run in MySQL to help narrow down the cause, and knowing the cause should make resolving it easier. Otherwise, all you're going to get here are guesses. – Greg Schmidt Oct 18 '16 at 22:01

1 Answers1

1

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.

Noahone
  • 91
  • 1
  • 2