如何使用 Doctrine2 和 MySQL 执行存储过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10705953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute Stored Procedures with Doctrine2 and MySQL
提问by unairoldan
I am working in a Symfony2 application and I need to use Stored Procedures to do some high performance processes.
我在 Symfony2 应用程序中工作,我需要使用存储过程来执行一些高性能进程。
There are any way to execute (and manage parameters) a MySQL Stored Procedure using Doctrine2?
有什么方法可以使用 Doctrine2 执行(和管理参数)MySQL 存储过程?
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();
采纳答案by a.aitboudad
you can use Native SQL and you could even use stored procedures for data retrieval.
您可以使用本机 SQL,甚至可以使用存储过程进行数据检索。
or you can view this link
或者您可以查看此链接