什么是可以在 PHP 5.3 上解析和重建 SQL 查询的优秀查询生成器?
我不需要 ORM。我很乐意自己编写针对性强且经过优化的查询,并且我不希望任何类型的 ORM 使我的代码变得臃肿。
我正在寻找一个轻量级、面向对象的查询解析器和构建器,可以将现有 SQL 字符串转换为可延展的查询构建对象,以便在数据库上重新编译和执行之前进行进一步操作。
用例本身正在更新对公共模式中的表执行的查询,这些表包含来自审核模式的替换表的当前有效信息,同时在 WHERE 子句中添加谓词以显示来自(新替换的)有效的时间点数据-时间状态表。
我的另一个用例是操作预先编写的查询以在执行之前提供额外的过滤器。
解析器/构建器将允许我编写当前有效的查询,但可以轻松地将它们转换为时间点等效查询。我目前正计划针对 Doctrine 2 的 QueryBuilder
进行重建部分。有谁知道有一个优秀的库可以将 SQL 查询解析为其基本组件吗?
I do not want an ORM. I am comfortable with writing heavily targeted and optimized queries on my own, and I do not want any sort of ORM bloating my code.
I am looking for a light-weight, object-oriented query parser and builder that can transform an existing SQL string into a malleable query building object for further manipulation before recompiling and executing on the database.
The use case itself is updating queries that execute against tables within a public schema that contain current-valid information with substitute tables from an auditing schema while adding predicates in the WHERE clause to present point-in-time data from the (newly substituted) valid-time state tables.
My other use case is to manipulate pre-written queries to provide additional filters before execution.
A parser / builder will allow me to write current-valid queries but transform them effortlessly into the point-in-time equivalent. I'm currently planning on raiding Doctrine 2's QueryBuilder
for the reconstruction part. Does anyone know of a an excellent library for parsing SQL queries into their base components?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个看起来不错(我没有使用过),但它不是 PHP——您可以通过使用 exec() 从 PHP 调用来运行 Java 单服务器端,并可能将其添加到您的脚本中
http://www.sqlparser.com/
This one looked pretty good (I have not used it), but it is not PHP -- you could run the Java one server side by invoking from PHP using exec() and possibly work it into your script
http://www.sqlparser.com/