atman atta Mon Jun 20 16:15:18 -0400 2011

Subject: How to invoke stored procedure?


I would like to invoke a stored procedure, is there a way to do this currently?
Thank you

Daniel Lowrey Mon Jun 20 18:14:26 -0400 2011

I don't believe you can do this strictly with php-activerecord at this time. Your best bet is to retrieve the PDO connection from your model and follow the examples in the PHP manual (#10 and #11) for calling a stored procedure using a PDO object:

To retrieve the connection object:

 1 // Retrieve the PDO object
 2 $pdo =  MyModel::connection()->connection
 4 // do stuff with your pdo connection object here ...
 5 $stmt = $pdo->prepare("CALL sp_returns_string(?)");
 6 $stmt->bindParam(1, $return_value, PDO::PARAM_STR, 4000); 
 8 // call the stored procedure
 9 $stmt->execute();
Mr. Carl Tue Nov 06 10:13:15 -0500 2012

You may be able to do this.. Take look at the model class function query and then follow it to connection class function query. It seem may be able to.,

(I was also looking for way to do this and found this by Google it. So I add my idea in case someone else Google it too.)