如何使用Doctrine2和MySQL执行存储过程 [英] How to execute Stored Procedures with Doctrine2 and MySQL
本文介绍了如何使用Doctrine2和MySQL执行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以执行(和管理参数)使用Doctrine2的MySQL存储过程?
解决方案:
code> $ em = $ this-> getDoctrine() - > getEntityManager();
$ qb = $ em-> createNativeQuery(
'CALL USR_P_UserRegistration('。
':iduser,,name,,surname,,birthday,:idlang,,idregistry'
')',
new ResultSetMapping()
);
$ qb-> setParameters(
array(
'iduser'=> $ c-> getIduser(),
'name'=> $ c-> ; getName(),
'surname'=> $ c-> getSurname(),
'birthday'=> $ c-> getBirthday(),
'idlang' => $ c-> getIdlang(),
'idregistry'=> $ c-> getIdregistry()
));
$ qb-> execute();
$ em-> flush();
解决方案
您可以使用Native SQL,甚至可以使用存储数据检索程序。
或者您可以查看此链接
I am working in a Symfony2 application and I need to use Stored Procedures to do some high performance processes.
There are any way to execute (and manage parameters) a MySQL Stored Procedure using Doctrine2?
SOLUTION:
$em = $this->getDoctrine()->getEntityManager();
$qb = $em->createNativeQuery(
'CALL USR_P_UserRegistration (' .
':iduser, :name, :surname, :birthday, :idlang, :idregistry' .
')',
new ResultSetMapping()
);
$qb->setParameters(
array(
'iduser' => $c->getIduser(),
'name' => $c->getName(),
'surname' => $c->getSurname(),
'birthday' => $c->getBirthday(),
'idlang' => $c->getIdlang(),
'idregistry' => $c->getIdregistry()
));
$qb->execute();
$em->flush();
解决方案
you can use Native SQL and you could even use stored procedures for data retrieval.
or you can view this link
How to use Stored Procedures with Symfony and Doctrine
这篇关于如何使用Doctrine2和MySQL执行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文