如何将存储过程与Symfony和Doctrine结合使用

时间:2021-09-12 07:07:14

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:

我在尝试用Symfony 1.4和Doctrine 1.2调用MySQL存储过程时遇到了一些问题。我想做的是:

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

在一个模块/new中输入表单中的所有数据后,我想在另一个表中插入一个值。

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

我不知道如果不使用存储过程,是否可以使用Doctrine。

Thanks for your help.

谢谢你的帮助。

2 个解决方案

#1


7  

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.

你可以使用触发器,但我不确定它们在MySQL中有多高级。触发器不会涉及任何原则、symfony或PHP中的编码。存储过程。

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

您可以通过Doctrine的记录侦听器或记录钩子获得非常类似的效果。

#2


0  

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

您可以使用Doctrine ine_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.

但是对于您的示例,似乎没有必要使用存储过程。相反,钩入控制器以添加其他记录,或者如kuba建议的那样,使用记录钩子。

#1


7  

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.

你可以使用触发器,但我不确定它们在MySQL中有多高级。触发器不会涉及任何原则、symfony或PHP中的编码。存储过程。

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

您可以通过Doctrine的记录侦听器或记录钩子获得非常类似的效果。

#2


0  

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

您可以使用Doctrine ine_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.

但是对于您的示例,似乎没有必要使用存储过程。相反,钩入控制器以添加其他记录,或者如kuba建议的那样,使用记录钩子。