php - Use mysql user variables in Zend Framework 2 -
I want to run a mysql query, including the variable. A simple version of this looks like this:
$ sql = "update mytable, (SELECT @ counter: = IFNULL (@ counter, 0) + 1 as new_value, mycolumn byothertable ORDER By mycolumn) I SET mytable.counter_column = i.new_value WHERE i.mycolumn = mytable.mycolumn "; $ This - & gt; GetSlaveSql () - & gt; GetAdapter () - & gt; GetDriver () - & gt; Mill Connection () - & gt; Execute ($ sql);
But the result value is always 1. If I run the query directly, then I have the correct line of numbers, I think the variable BE will not be able to unset the BE Zend, so that each line has a @ counter 0.
I have used a stored procedure for this now.
Comments
Post a Comment