将原始 SQL 与 Doctrine 结合使用 [英] Using Raw SQL with Doctrine
问题描述
我需要使用一些极其复杂的查询来在我的应用程序中生成报告.我使用 symfony 作为我的框架和学说作为我的 ORM.
I have some extremely complex queries that I need to use to generate a report in my application. I'm using symfony as my framework and doctrine as my ORM.
我的问题是这样的:
在不将它们转换为 Doctrine 查询语言的情况下,将高度复杂的 sql 查询直接传递给 Doctrine 的最佳方法是什么?我一直在阅读有关 Raw_SQL
扩展的信息,但您似乎仍需要分段传递查询(如 from()
).有什么东西可以只转储一堆原始的 sql 命令吗?
What is the best way to pass in highly-complex sql queries directly to Doctrine without converting them to the Doctrine Query Language? I've been reading about the Raw_SQL
extension but it appears that you still need to pass the query in sections (like from()
). Is there anything for just dumping in a bunch of raw sql commands?
推荐答案
$q = Doctrine_Manager::getInstance()->getCurrentConnection();
$result = $q->execute(" -- RAW SQL HERE -- ");
查看 Doctrine API 文档了解不同的执行方法.
See the Doctrine API documentation for different execution methods.
这篇关于将原始 SQL 与 Doctrine 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!