有人能告訴我,如何從$em->find()
方法中獲取純SQL?
回答
你的問題不清楚。
- 如果您的意思是「是否可以使用原始SQL查找對象」,請檢查Native SQL section in the Doctrine 2 documentation;
- 如果您的意思是「是否可以查看由Doctrine查詢生成的SQL」,則配置一個SQL記錄器,如this answer中所述。
我知道,可以從'$ entity_manager-> createQuery()'''getSQL()'方法獲得原始SQL。我問,如果可以從'$ entity_manager-> find()'方法獲得原始SQL。 – 2012-07-21 19:07:58
SQL記錄器爲您提供了由Doctrine 2生成的* all *查詢的輸出。如果您只是需要此信息進行調試,那麼它將完成這項工作。 – Benjamin 2012-07-21 21:34:34
可以給我一些關於如何使用它的指示嗎? – 2012-07-21 21:45:13
- 1. Doctrine 2 ManyToOne with multiple joinColumns
- 2. Doctrine 2 PlainValue expected
- 3. Symfony2,Doctrine 2:getResult Object
- 4. 從find中找到./ from filename -execdir
- 5. Doctrine 2.x CRUD
- 6. 加入entity.collection Doctrine 2
- 7. Doctrine 2錯誤
- 8. doctrine 2 dql alias
- 9. Doctrine 2 ManyToMany cascade
- 10. Doctrine 2子查詢
- 11. Doctrine 2和SVN Externals
- 12. doctrine 2 setHydrator錯誤
- 13. Doctrine 2,ManyToMany搜索
- 14. Slim 3與Doctrine 2
- 15. Doctrine 2編輯實體DQL
- 16. Doctrine 2命令行工具; MAMP和mysql.sock
- 17. Doctrine 2中的'name'屬性
- 18. Doctrine 2多級OneToOne級聯
- 19. Symfony3/Doctrine 2刷新錯誤
- 20. Doctrine 2註釋和「var」
- 21. Doctrine 2中TRUNCATE的getResult()
- 22. 使用PEAR安裝Doctrine 2
- 23. Doctrine 2 ArrayCollection過濾方法
- 24. 使用onDelete與Doctrine 2
- 25. Doctrine 2關閉連接
- 26. Doctrine 2重複檢測
- 27. Doctrine 2 OneToMany Cascade SET NULL
- 28. Doctrine 2和CodeIgniter入門
- 29. asp.net mvc 2 model not from db
- 30. Ionic 2:src from img not updating
爲什麼你需要這個?爲了調試目的?如果這是你想要做的,我會建議mysql查詢日誌。 – Max 2012-07-21 20:24:51
@Max是的,但是,如果我不使用MySql:>? – 2012-07-21 20:38:13
你應該,它有一個查詢日誌:> – Max 2012-07-21 20:46:18