Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got caught by the exact same bug myself a few days ago. I believe it's caused by a bug in the Timestampable behavior. I'm guessing you have it enabled in the Product model, and Doctrine adds the updated_at field into the series of fields to update (SET) and doesn't pay attention to the fact that you have SQL parameters after that (in the where clause). This bug never comes up when doing SELECTs because Timestampable isn't involved.</p> <p>The only solution I found is to supply the parameters as you build the query rather than in the execute's array parameter and Doctrine won't get confused. Like this:</p> <pre><code>$q-&gt;update('product') -&gt;set('quantity', 20) -&gt;where('id = ?', 5); $q-&gt;execute(); </code></pre> <p>However if you need to run the same query many times with different values, you'd be losing the performance benefits of separate prepare &amp; execute phases. It appears this is the only solution.</p> <p>Potentially better solution without performance loss: I have not verified this, however, I would hope that bug would not surface if you used named parameters instead of the anonymous ? placeholders. Doctrine's support for named parameters is described here: <a href="http://www.doctrine-project.org/documentation/manual/1_2/en/dql-doctrine-query-language" rel="nofollow">http://www.doctrine-project.org/documentation/manual/1_2/en/dql-doctrine-query-language</a></p> <p>EDIT: I have since tried the alternate approach with named parameters and unfortunately the bug remains. Doctrine gives an error saying you can't mix named and anonymous parameters in the same query. This really should have been fixed a long time ago IMO.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload