MySQL Forums
Forum List  »  PHP

Re: stored procedure out parameter problem in php page using mysql
Posted by: Erik Aarts
Date: July 20, 2008 07:53AM

This was really helpful! My procedure, however, uses a char IN parameter.

$ivalue='mytext';
$res = $mysqli->multi_query( "CALL myproc('$ivalue',@x);SELECT @x" );

It took me quite some time to discover that you have to quote twice :-(
myproc('$ivalue' instead of myproc($ivalue

Furthermore I discovered that sometimes resultsets are "skipped". This becomes clear if you change the ++$results, and add 1 to $results in every loop.

<?php
$link = new mysqli('localhost', 'root', '','test') or die ('Error connecting to mysql: ' . mysqli_error($link));

$proc = $_GET["proc"];
$arg1 = $_GET["arg1"];
$res = $link->multi_query("call ".$proc."('$arg1',@retval,@error);SELECT @retval,@error");

if( $res ) {
  $results = 0;
  do {
    $results = $results + 1;
    if ($result = $link->store_result()) {
      printf( "<b>Result #%u</b>:<br/>", $results );
      while( $row = $result->fetch_row() ) {
        foreach( $row as $cell ) echo $cell, "&nbsp;";
        echo "<br/>";
      }
      $result->close();
      if( $link->more_results() ) echo "<br/>";
    }
  } while( $link->next_result() );
}

$link->close();
?>



Edited 6 time(s). Last edit at 07/23/2008 01:18PM by Erik Aarts.

Options: ReplyQuote


Subject
Written By
Posted
Re: stored procedure out parameter problem in php page using mysql
July 20, 2008 07:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.