Snippets

Create an account or login to be able to add, comment and rate snippets.

Navigation

Executing a MySQL stored procedure

It took me quite some time but here is how to execute a MySQL stored procedure.

$connection = Propel::getConnection();
 
$query = 'CALL Proc(%s, %s, %s)';    
$query = sprintf($query, $var1, $var2, $var3);
 
$mysqli = $connection->getResource();
if($mysqli->multi_query($query)){
  do{
    if($result = $mysqli->use_result()){
      while($row = $result->fetch_assoc()){
        //
      }
      $result->free();
    }
  } while(($mysqli->next_result()));
}
 

Note that you should be using mysqli in order for this to work properly.

by Marcel van Leeuwen on 2008-04-18, tagged model  mysqli  propel  sql 

Comments on this snippet

gravatar icon
#1 nei santos on 2008-05-01 at 04:52

Hi Marcel,

i'm needing it, but for docrtine, do you know how i use it in doctrine??

thanks..

nei

You need to create an account or log in to post a comment or rate this snippet.