Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute Stored Procedures with Symfony2, Doctrine2

I am using the following code:

use Doctrine\ORM\Query\ResultSetMapping;
...
...
...
...
$em    = $this->get( 'doctrine.orm.entity_manager' );
$rsm   = new ResultSetMapping();
$query = $em->createNativeQuery( 'CALL procedureName(:param1, :param2)', $rsm )
            ->setParameters( array(
                'param1' => 'foo',
                'param2' => 'bar'
            ) );
$result = $query->getResult();
//$result = $query->execute(); // Also tried

$em->flush();
die(var_dump($result));

I am not getting any thing in the $result parameter. Can anyone please tell me how to get the result from a stored procedure in Symfony 2.0.15 ?

like image 991
Rashy Avatar asked Oct 06 '22 14:10

Rashy


1 Answers

You haven't added any resultset mapping info. See here for sample.

like image 121
Mun Mun Das Avatar answered Oct 10 '22 02:10

Mun Mun Das