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.

3
  • 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 Commented Nov 16, 2013 at 20:30
  • Can`t you use PDO with transactions...? And beeing a cron job you can process huge data if needed... Commented Nov 16, 2013 at 20:37
  • What does this function/procedure accomplish? Commented Nov 16, 2013 at 20:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.