[英]Doctrine and stored procedure after connection commit
I'm trying to call a stored procedure in my project, AFTER an object is saved (like a trigger would do, but MySQL doesn't allow calling stored procedure within a trigger). 我试图在我的项目中调用存储过程,然后保存对象(就像触发器一样,但是MySQL不允许在触发器内调用存储过程)。
First try : I wrote the call in the postInsert() hook, in Doctrine_Record. 首先尝试:我在Doctrine_Record的postInsert()挂钩中编写了该调用。 At this moment, the transaction is not committed to the database, so wrong way. 此时,事务没有提交给数据库,所以方式错误。
Second try : I wrote an EventListener and call the postTransactionCommit() event. 第二次尝试:我编写了一个EventListener并调用postTransactionCommit()事件。 It works fine, except that I'm not able at this level to know what table was modified. 它工作正常,除了我无法在此级别知道修改了哪个表。 I can know what tables are 'initialized' in this connection, but that's all. 我知道在此连接中哪些表已“初始化”,仅此而已。 And I don't want to call my stored procedure if I'm doing only a SELECT in the transaction. 而且,如果我在事务中仅执行SELECT,则不想调用存储过程。
So now I'm stucked... Do you see a lead I did not follow? 所以现在我被困住了...您看到我没有遵循的线索了吗?
Thanks 谢谢
我通过重写Doctrine_Record中的save()方法解决了该问题,因此在save()之后才建立连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.