Zendの構成は次のとおりです:resources.db.adapter = "pdo_mysql"
メッセージを取得するクエリ :SQLSTATE [HY000]:一般エラー
$db = Zend_Db_Table::getDefaultAdapter();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
$qry = $db->fetchAll(" SET @rank = 0 ;
SELECT
@rank := @rank +1 AS rank,
SUM(user_scoring_data.user_points) AS user_points,
league_team.user_id
FROM league_team
RIGHT JOIN user_scoring_data ON league_team.league_team_id = user_scoring_data.league_team_id
WHERE league_id = '$league_id' GROUP BY user_scoring_data.league_team_id
ORDER BY user_points DESC"
);
mysql変数を削除すると、機能します。
$db->fetchAll("
SELECT
SUM(user_scoring_data.user_points) AS user_points,
league_team.user_id
FROM league_team
RIGHT JOIN user_scoring_data ON league_team.league_team_id = user_scoring_data.league_team_id
WHERE league_id = '$league_id' GROUP BY user_scoring_data.league_team_id
ORDER BY user_points DESC"
);
*注:クエリはphpmyadminで直接テストされており、エラーはありません。