drupal 7 db_query错误
print_r($sql);
echo "\n";
print_r($sql_params);
$result = db_query($sql, $sql_params); // Error happening here
输出:
select SQL_CALC_FOUND_ROWS * from rocdocs_database_1318520218 where 1=1 order by ? ? limit ?, ?
Array
(
[0] => c5
[1] => desc
[2] => 0
[3] => 50
)
根据文档,我可以通过使用数组和 ? 来使用有序参数。标记,但似乎有错误。有什么方法可以调试这个吗?我已经安装了 devel,但它不显示查询。
print_r($sql);
echo "\n";
print_r($sql_params);
$result = db_query($sql, $sql_params); // Error happening here
Output:
select SQL_CALC_FOUND_ROWS * from rocdocs_database_1318520218 where 1=1 order by ? ? limit ?, ?
Array
(
[0] => c5
[1] => desc
[2] => 0
[3] => 50
)
According to the documentation I can used ordered parameters by using an array and ? marks, but it seems to be erroring. Any ways to debug this? I have installed devel, but it doesn't show the query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能对任何“sql 结构”(如排序定义、表/列名称等)使用占位符。这是不可能的。
如果您需要按定义进行动态排序,请使用 db_select(),然后使用 orderBy()。确保验证您通过该传递的内容。
You can't use placeholders for anything that is "sql structure" like sort definitions, table/column names and so on. This is impossible.
If you need dynamic order by definitions, use db_select() and then orderBy(). Make sure to validate what you pass in through that.