有没有一个工具可以将静态 SQL 字符串转换为有效的 Drupal 数据库查询代码?

发布于 2024-09-19 18:24:30 字数 1536 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一紙繁鸢 2024-09-26 18:24:30

我认为没有这样的工具。
请阅读:
sql 编码约定
http://drupal.org/writing-secure-code

i assume there's no such tools.
Just read:
sql coding conventions
http://drupal.org/writing-secure-code

或十年 2024-09-26 18:24:30

这可能会节省一些时间,具体取决于您尝试使用 SQL 执行的操作。

http://drupal.org/project/views

This might save some time, depending on what you are trying to do with SQL.

http://drupal.org/project/views

何以笙箫默 2024-09-26 18:24:30

普通的非 Drupal SQL 仍然可以在 db_query 中工作...这不是最佳实践,因为数据库 API 无法重新调整 SQL 以在任何支持的环境中工作,并且不能利用 Drupal 的 SQL 注入保护,除其他事项外。

但它仍然有效。

如果您打算在已知环境中使用 SQL(例如,已经在使用这些命令的系统),我会说暂时按原样使用它们,并随着新代码的出现逐渐将它们转换为 Drupal 标准。发达。

(当然,如果此代码要分发到其他环境,您将需要投入汗水并转换字符串,或者编写一个工具来执行此操作)

Plain 'ol non-Drupal SQL will still work in db_query ... it's just not a best practice since the database API can't retool the SQL to work in any supported environment, and doesn't take advantage of Drupal's SQL injection protections, among other things.

But it still works.

If you're going to use the SQL in a known environment (e.g. a system where these commands are already in use), I'd say just use them as they are for now and gradually convert them over to Drupal standards as new code is developed.

(Of course, if this code is meant to be distributed to other environments, you'll want to put in sweat equity and convert the strings, or write a tool to do so)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文