This topic is locked
[SOLVED]

 Correct update query producing error 256 with phprunner

10/21/2017 5:44:53 AM
PHPRunner General questions
mbintex author

I have this update query

set @kilometerstand:=0;

update Fahrten

set Kilometerstand=(@kilometerstand:=@kilometerstand+Kilometer)

where Fahrzeug=1

order by Abfahrtszeit


and it works without any errors or problems in MySQL workbench.
When I create an event in phprunner and have this

$sql="set @kilometerstand:=0; update Fahrten set Kilometerstand=(@kilometerstand:=@kilometerstand+Kilometer) where Fahrzeug=".$values['Fahrzeug']." order by Abfahrtszeit";
CustomQuery($sql);


which should result in the same, I only get an PHP error 256 - error in the SQL statement.
DB_Exec produces the same problem. What´s going on here?
I simply want to write the result of a calculated running total to the database.

H
headingwest 10/21/2017

Try putting it into a stored procedure then calling that. There's documentation on calling SPs but I'm on my phone so can't link to it for you.

mbintex author 10/22/2017

Perhaps I have to go that way, but currently I see that as a workaround.
https://xlinesoft.com/phprunner/docs/how_to_execute_sql_server_stor.htm

mbintex author 10/23/2017

support wrote me and had another possible solution:
you cannot use our API to execute queries that contain more than one statement in event code.
You can write your own code though that will do the same:

http://php.net/manual/en/mysqli.multi-query.php