cakephp:row_number
クエリ結果に自動采番
MySQL/oracleのrow_numberっぽい動き も参考
サンプルソース
public function test() { $sql = "SET @r=0"; $this->Ranking->query($sql); $sql = "SELECT (@r:=@r+1) as row, id, name, (victory/games) as victory_rate, image_url, team_info_id FROM users WHERE games > ? ORDER BY victory_rate DESC LIMIT ?"; $val = $this->Ranking->query($sql, array(0, 100)); debug($val); }
cakephp/row_number.txt · 最終更新: 2014/02/26 07:16 by clownclown