0

I am getting this the following MAX_JOIN_SIZE error when I deploy my cakephp v3 app to shared hosting:

    Error: SQLSTATE[42000]: Syntax error or access violation: 1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay

This seems like a common problem, but can anyone tell me how to get round this when using cakephp v3.x? I have tried putting the following code in app/src/Model/AppModel.php:

    function beforeFind()   {
        $this->query('SET SQL_BIG_SELECTS=1');
    }

but this doesn't seem to have any effect.

pkbevans
  • 23
  • 4

1 Answers1

0

CakePHP 3.0 doesn't use an AppModel anymore. You really should read the migration guide. Implement it via an event listener on Model.beforeFind or as a behavior.

Further setting SQL_BIG_SELECTS to 1 seems like bad practice to me. You should not work around the symptoms but fix the cause: Figure out what's wrong with your query.

See MySQL - SQL_BIG_SELECTS which has a good answer.

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66
  • I took your advice and found another way to achieve what I wanted to do. My original solution was more elegant and wasn't a ridiculous number of joins, but hey ho... – pkbevans Nov 30 '16 at 09:02