更新时间:2023-10-06 11:36:52
很遗憾,您不能在 Order By 子句中直接使用 CFQUERYPARAM.
Unfortunately, you can't use CFQUERYPARAM directly in the Order By clause.
如果您想动态地使用 Order By 但仍然可以安全地使用,您可以设置一个 CFSWITCH 或类似的结构来根据某些条件(例如 URL 变量)更改您的 SortBy 变量.与往常一样,不要直接从用户传递任何值,只需查看用户的输入并基于此从预定的可能值列表中进行选择.然后,只需使用标准语法:
If you want to use the Order By dynamically but still do so safely, you can set up a CFSWITCH or similar structure to change your SortBy variable depending on some condition (say, a URL variable). As always, don't pass any values directly from the user, just look at the user's input and select from a predetermined list of possible values based on that. Then, just use the standard syntax:
ORDER BY #SortBy#