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();
Create a simple stored procedure. DELIMITER ; To create the MySQL Stored Procedure, open the MySQL workbench Connect to the MySQL Database copy-paste the code in the query editor window click on Execute. You can view the procedure under stored procedures.
Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure. In the Execute Procedure dialog box, specify a value for each parameter and whether it should pass a null value.
you can use Native SQL and you could even use stored procedures for data retrieval.
doc Native sql
or you can view this link
How to use Stored Procedures with Symfony and Doctrine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With