Hi all,

I can execute stored procedure, but how to retrieve the output value ?
(worked with ZF1 but not ZF2)

// This part work, is how i execute a stored procedure... 

public function save(MyStuff $vo)
{
         // Get adapter
        $dbAdapter = $this->tableGateway->getAdapter();

        $stmt = $dbAdapter->createStatement();
        $stmt->prepare('CALL sp_save_mystuff(?,?)');
        $stmt->getResource()->bindParam(1, $vo->id, \PDO::PARAM_INT);
        $stmt->getResource()->bindParam(2, $vo->name);
        $stmt->execute();
}
    

// Now i would like retrieve a output parameter like the id generated by the
database

public function save(MyStuff $vo)
{
        // Get adapter
        $dbAdapter = $this->tableGateway->getAdapter();

        $stmt = $dbAdapter->createStatement();
        $stmt->prepare('CALL sp_save_mystuff(?,?, @out)');   <---- ADDED THIS 
@out
        $stmt->getResource()->bindParam(1, $vo->id, \PDO::PARAM_INT);
        $stmt->getResource()->bindParam(2, $vo->name);
        $stmt->execute();

        // Retrieve out parameter
       return $dbAdapter->query("SELECT @out")->fetchColumn();  <---- THIS
NOT WORK
}

I found nothing about it in documentation.

Thanks in advance!




--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Stored-procedure-with-out-parameter-tp4660072.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to