Query number in mysqli_multi_query iteration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Query number in mysqli_multi_query iteration

Post by anjanesh »

When using mysqli_multi_query, is there a way to find out the current query ($sql1, $sql2 or $sql3) while iterating ?

Code: Select all

$sql = $sql1.$sql2.$sql3;
if ($mysqli->multi_query($sql))
 {
        do
         {
                /*
                switch ($mysqli->queryNumber)
                 {
                        case 1: ... break; # $sql1
                        case 2: ... break; # $sql2
                        case 3: ... break; # $sql3
                 }
                */
                if ($result = $mysqli->store_result())
                 {
                        while ($row = $result->fetch_assoc())
                         {
                                echo $row['Name'].'<br/>';
                         }
 
                 }
                if ($mysqli->more_results())
                 echo '<hr/>';
 
         } while ($mysqli->next_result());
 }
else
 {
        echo $mysqli->errno." : ".$mysqli->error;
 }
Thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Query number in mysqli_multi_query iteration

Post by RobertGonzalez »

Set a counter.
Post Reply