# Cake PHP generating wrong query

**URL:** <https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549>\
**Category:** Need Help\
**Tags:** help\
**Created:** [October 26, 2020, 6:10pm UTC](https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549 "2020-10-26T18:10:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vncssj](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/vncssj/32/2018_2.png) [@vncssj](https://discourse.cakephp.org/u/vncssj)\
**Post date:** [October 26, 2020, 6:10pm UTC](https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549/1 "2020-10-26T18:10:29Z")

</div>

Hello guys, all right?  
So…recently my team need to do a migrate servers, and we had a delicious idea update the PHP, so our PHP is 7.2, but yet was 5.6, and after this changes, the cakephp, show many errors were never was accused, and the principal is below.

My code:  
`$pfProfissoes = $this->PfCalculos->PfProfissoes->find('list', ['valueField' => 'nome']);`

And cake return:

**Error:** SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

The query builded:

`SELECT PfProfissoes.id AS `PfProfissoes\_\_id`, PfProfissoes.nome AS `PfProfissoes\_\_nome` FROM pf_profissoes PfProfissoes WHERE`

Atenciously,  
Sorry for my english

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [October 26, 2020, 6:34pm UTC](https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549/2 "2020-10-26T18:34:46Z")

</div>

That’s all there is to the query? It just ends with “WHERE”?

What version of CakePHP are you running?

---

<div class="post-metadata">

**Author:** ![vncssj](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/vncssj/32/2018_2.png) [@vncssj](https://discourse.cakephp.org/u/vncssj)\
**Post date:** [October 26, 2020, 7:09pm UTC](https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549/3 "2020-10-26T19:09:38Z")

</div>

Yes, this is the end, and I don’t know where that “Where” comes from.  
But before our migrate, this code worked fine, and now not.  
My cakephp version is 3.2.13

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [October 26, 2020, 7:45pm UTC](https://discourse.cakephp.org/t/cake-php-generating-wrong-query/8549/4 "2020-10-26T19:45:32Z")

</div>

I have long thought that it would be useful to have a list somewhere of Cake versions and what PHP versions they support. I suppose that’s hard to maintain. 3.2 with 7.2 seems like it might be a problem, there have been others here and elsewhere reporting issues with that combination. Might be worth trying to update Cake to maybe 3.4? I think that’s a pretty straight-forward migration; moving to where middleware is implemented is a bigger change. Or try PHP 7.1?
