Answer the question
In order to leave comments, you need to log in
Same MySQL query works through PhpMyAdmin but doesn't work through script?
I do not understand. There is such a request (you need to select the position of the player ± 2 positions, it didn’t work out better).
$uid = 2;<br/>
$rate_table = $this->db->query('SET @rank=0;<br/>
CREATE TEMPORARY TABLE `rank_table` AS (<br/>
SELECT @rank:[email protected]+1 AS rank,`users`.*,IFNULL(SUM(`g`.`units`),0) as sum<br/>
FROM `users`<br/>
LEFT OUTER JOIN (SELECT * FROM `game_rounds` WHERE `game_rounds`.`final`=1) g ON `users`.`id`=`g`.`uid`<br/>
GROUP BY `users`.`id`<br/>
ORDER BY `sum` DESC<br/>
);<br/>
SET @user_rank = (SELECT `rank` FROM `rank_table` WHERE `id`='.$uid.');<br/>
SELECT * FROM `rank_table` WHERE `rank`<[email protected]_rank+2 AND `rank`>[email protected]_rank-2')->result();
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TEMPORARY TABLE `rank_table` AS ( SELECT @rank:[email protected]+1 AS rank,`users`' at line 2
Answer the question
In order to leave comments, you need to log in
Break requests by; and do them one by one. Multiqueries may not be executed depending on the settings on a particular server.
There is also such a thing as mysqli_multi_query , but I'm not sure that it can be easily screwed with CodeIgniter
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question