0

I want to execute this query in php page.

the query:

BEGIN
SET @p=0;
UPDATE users SET cityrate = (@p:=@p+1) WHERE cityid=1 ORDER BY power DESC;
END

options (that dont work) that i already tried:

mysql_query(" BEGIN
SET @p=0;
UPDATE users SET cityrate = (@p:=@p+1) WHERE cityid=1 ORDER BY power DESC;
END");

and

mysql_query("SET @p=0;
UPDATE users SET cityrate = (@p:=@p+1) WHERE cityid=1 ORDER BY power DESC;");

Till now used this query on events but events aren't allowed on some hosts. so I am going to use this on cronjobs.

Pls help me.

  • The `mysql_*()` API does not support multiple statements in one `mysql_query()` call. First execute `mysql_query("SET @p=0")` then execute the update statement in another `mysql_query()` call – Michael Berkowski Nov 16 '13 at 20:30
  • Can`t you use PDO with transactions...? And beeing a cron job you can process huge data if needed... – ka_lin Nov 16 '13 at 20:37
  • What does this function/procedure accomplish? – ka_lin Nov 16 '13 at 20:42

0 Answers0