Reputation: 2863
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();
Upvotes: 15
Views: 27804
Reputation: 1652
$entityManager = $this->doctrine->getManager();
$sql="CALL procedure(parameter);";
$stmt = $entityManager->getConnection()->prepare($sql);
$stmt->execute();
Upvotes: -1
Reputation: 4092
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
Upvotes: 6