# how to fix find() query that stopped working after php-mysql upgrade

**URL:** <https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562>\
**Category:** Need Help\
**Created:** [August 30, 2019, 1:57pm UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562 "2019-08-30T13:57:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![agtechno](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@agtechno](https://discourse.cakephp.org/u/agtechno)\
**Post date:** [August 30, 2019, 1:57pm UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/1 "2019-08-30T13:57:37Z")

</div>

A few cakephp find() functions stopped working after a server migration from php 5.2 to 5.4 and mysql 5.1 to 5.7. I am trying to fix them but according to the cake manual I do not see anything that could be wrong.

I have tried modifying the ‘conditions’ part that seems to be what is causing the problem to no avail. the function does not return anything.

```auto
function infoServorder($ev_id){
    return $this->find('all', array(
        'link' => array(
            'Service' => array(
            'QuestionnairesService' => array('Questionnaire' => array('conditions' => 'QuestionnairesService.questionnaire_id = Questionnaire.id'),
            'conditions' => 'Service.id = QuestionnairesService.service_id'
                                            ),
            'conditions' => 'Service.id = Evaluation.service_id'
            )
        ),
        'fields' => array('Evaluation.order_id','Service.id','Service.name'),           
        'conditions' => array('Evaluation.id' => $ev_id, 'Questionnaire.type_q' => 'TSP'),
        'order' => array('Questionnaire.id ASC')
));                     

}   

```

I try to get the ‘fields’ =\> array(‘Evaluation.order\_id’,‘Service.id’,‘Service.name’) printed on the screen in order to move forward but the function doesn’t return anything.

I have a second function that is very similar and it returns all its fields ok.

---

<div class="post-metadata">

**Author:** ![Ruslan](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Ruslan](https://discourse.cakephp.org/u/Ruslan)\
**Post date:** [August 31, 2019, 10:31am UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/2 "2019-08-31T10:31:11Z")

</div>

Try to copy-paste your query to mysql console.  
I think it’s related with some changes in MySQL 5.7

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [August 31, 2019, 10:31pm UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/3 "2019-08-31T22:31:34Z")

</div>

Is debug set to true so you can see any errors.

---

<div class="post-metadata">

**Author:** ![Ruslan](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Ruslan](https://discourse.cakephp.org/u/Ruslan)\
**Post date:** [September 1, 2019, 7:41am UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/4 "2019-09-01T07:41:12Z")

</div>

One more case, memory limit.

---

<div class="post-metadata">

**Author:** ![agtechno](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@agtechno](https://discourse.cakephp.org/u/agtechno)\
**Post date:** [September 4, 2019, 9:27pm UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/5 "2019-09-04T21:27:03Z")

</div>

Hi Ruslan, thanks for the help. I already considered MySQL new version as a possible cause for things not to work 100%. I was able to paste the generated query directly onto the MySQL editor and got an error that pointed straight to the problem, which was STRICT\_TRANS\_TABLES being set to true on the SQL\_Mode variable. I removed it and things started working the way they’re supposed.

Thanks for the suggestion it helped a lot!

---

<div class="post-metadata">

**Author:** ![agtechno](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@agtechno](https://discourse.cakephp.org/u/agtechno)\
**Post date:** [September 4, 2019, 9:30pm UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/6 "2019-09-04T21:30:12Z")

</div>

hi jimgwhit, One of the problem s I have been facing since this migration started is that I often have no clue about the errors because the actual debug kit broke. I activated it since the beginning and all I get are a bunch of errors or warnings, generally about non-static objects being called statically. I tried to edit some of the files and most of the errors disappeared. I could not get it to work again though…

---

<div class="post-metadata">

**Author:** ![Ruslan](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Ruslan](https://discourse.cakephp.org/u/Ruslan)\
**Post date:** [September 5, 2019, 7:07am UTC](https://discourse.cakephp.org/t/how-to-fix-find-query-that-stopped-working-after-php-mysql-upgrade/6562/7 "2019-09-05T07:07:03Z")

</div>

BTW, if you migrate now, better to use MySQL 8.  
I had the same situation couple months ago.
