munkey Posted August 1, 2013 Share Posted August 1, 2013 (edited) Hi, I recently migrated to mysqli after reading the old type is going to be phased out, but I dont understand how you identify queries: //Assume $db is already instantiated $db->query("SELECT xyz FROM abc....."); //Query 1 $db->query("SELECT efg FROM def....."); //Query 2 $db->query("SELECT pqr FROM hij....."); //Query 3 //Here I want to see how many rows are in query 1 and return an array for query 2 How do I tell the $db->num_rows property what query to look at as it does not have any parameters? ...and the same goes with fetching arrays and so fourth; all of these methods do not take any parameters regarding what query they are using. As far as I can see the only way would be to have one query per $db object which can't be true. Thanks. Edited August 1, 2013 by munkey Quote Link to comment https://forums.phpfreaks.com/topic/280703-mysqli-identifying-multiple-queries-on-same-object/ Share on other sites More sharing options...
Solution requinix Posted August 1, 2013 Solution Share Posted August 1, 2013 (edited) You do exactly the same thing as you did with the mysql_* functions: execute the query, assign the result somewhere, and look it later. $q1 = $db->query("SELECT xyz FROM abc....."); //Query 1 $q2 = $db->query("SELECT efg FROM def....."); //Query 2 $q3 = $db->query("SELECT pqr FROM hij....."); //Query 3 echo "query 1 returned {$q1->num_rows} rows\n"; echo "first row of query 2 is " . implode(", ", $q2->fetch_array()), "\n"; echo "query 3 has {$q3->field_count} columns\n"; Edited August 1, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/280703-mysqli-identifying-multiple-queries-on-same-object/#findComment-1442905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.