How to use Stored Procedures with Symfony and Doctrine

放肆的年华 提交于 2020-01-14 08:41:27

问题


I having problems at trying to call a MySQL Stored Procedure with Symfony 1.4 and Doctrine 1.2. What I want to do is the following:

In a module/new after typing all the data in the form, I want to insert one of the values in another table.

I don't know if this can be done with Doctrine without using a stored procedure.

Thanks for your help.


回答1:


You could use triggers but I'm not sure how advanced they are in MySQL. Triggers wouldn't involve any coding in Doctrine, symfony nor PHP. Just stored procedures.

You can achieve pretty similar effect with Doctrine's record listeners or record hooks.




回答2:


You can achieve this this using Doctrine_RawSQL Cf. Doctrine API ref

But for your example, there seems to have no need to use stored procedures. Instead hook into controller to add others records, or, as kuba suggested use records hooks.



来源:https://stackoverflow.com/questions/3198647/how-to-use-stored-procedures-with-symfony-and-doctrine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!