如何使用Doctrine2和MySQL执行存储过程

时间:2022-09-15 19:02:31

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();

1 个解决方案

#1


7  

you can use Native SQL and you could even use stored procedures for data retrieval.

您可以使用本机SQL,甚至可以使用存储过程进行数据检索。

doc Native sql

医生原生sql

or you can view this link

或者你可以查看这个链接

How to use Stored Procedures with Symfony and Doctrine

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

#1


7  

you can use Native SQL and you could even use stored procedures for data retrieval.

您可以使用本机SQL,甚至可以使用存储过程进行数据检索。

doc Native sql

医生原生sql

or you can view this link

或者你可以查看这个链接

How to use Stored Procedures with Symfony and Doctrine

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