プロジェクトで Doctrine DBAL を使用しようとしています。私のデータベースは Postgresql です。これは単純な使用例であり、なぜこれが機能しないのか本当にわかりません。
$query = "SELECT * FROM table ORDER BY field :order LIMIT :amount";
次のように仮定します。
$order = 'DESC' and $amount = 'ALL';
上記のコードは問題ないようです。
$statement = $app['db']->prepare($sql);
$statement->bindValue('order', $order);
$statement->bindValue('amount', $amount);
$statement->execute();
次のエラーが表示されます。
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1"
LINE 1: SELECT * FROM table ORDER BY field $1 LIMIT $2
誰かがこの動作を説明できますか? 私は引用の問題を疑っています...
よろしく
カミル