Reputation: 11
Why it don't work? How i can call stored procedure?
$rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->objectManager);
$query = $this->objectManager->createNativeQuery('call `ftemplate_setcell`(:t, :col, :row, :p, :r, :v)', $rsm)->
setParameters($this->data);
$query->Execute();
$this->objectManager->flush();
Upvotes: 0
Views: 1595
Reputation: 1678
To execute a stored procedure or function you can do it using the connection itself as the following:
$conn = $this->getServiceManager()->get('doctrine.entitymanager.orm_default')->getConnection();
$stmt = $conn->prepare($storedProcedureSQL);
$stmt->bindParam(':param1', $param1);
$stmt->bindParam(':param2', $param2);
$stmt->execute();
and if you have an output parameter you can get it by the following binding:
$stmt->bindParam(':outputParam', $outputParam, \PDO::PARAM_INPUT_OUTPUT, 32);
And after executing the statement you can use the variable $outputParam
which holds the function or procedure output parameter value.
Upvotes: 5