Stored procedure causes “Commands out of sync” on the next query

前端 未结 5 1562
不知归路
不知归路 2020-12-16 04:58

I am running a query with a mysql stored procedure :

$AddProf_qr = mysql_query(\"call AddStudent(\'$d_Pass\', \'$d_Titl\', \'$d_Firs\', \'$d_Midd\',  \'$d_La         


        
5条回答
  •  既然无缘
    2020-12-16 05:43

    @DMin Yes that's would work, but you'll crash the server sooner or later. Just make the math, one resquest to a page that makes 3 * number of procedures to database! Just think about it!

    [UPDATE] solution:

    $aCategory = array();
    $it=0;
    $res = $mysqli->multi_query( "call ListCategory();" );
    if( $res ) {
      do {
        if ($result = $mysqli->store_result()) { 
    
            while( $row = $result->fetch_row() ) {
                    $aCategory[$it] =$row;
                    $it= $it + 1;
            }
            $result->close();
        }
      } while( $mysqli->next_result() );
    }
    
    foreach($aCategory as $row){
        echo . $row[0] . " - " . $row[1] . "
    "; }

    Just wanted to add that you are ready to call the next Routine.

    PS: By this way I couldn't use

    echo $aCategory['category_id'] ; 
    //or 
    echo $aCategory->category_id;
    //just
    echo $aCategory[0] 
    

提交回复
热议问题