PHP Classes

multiple queries

Recommend this page to a friend!

      Ultimate MySQL  >  All threads  >  multiple queries  >  (Un) Subscribe thread alerts  
Subject:multiple queries
Summary:multiple queries
Messages:2
Author:Chris Beech
Date:2014-01-31 13:41:34
 

  1. multiple queries   Reply   Report abuse  
Picture of Chris Beech Chris Beech - 2014-01-31 13:41:34
how do i use multiple queries .ie.

$result1 = $db->Query($sql1);
$result2 = $db->Query($sql2);


while($row1 = $db->Row()
{
echo "Something";
}

while($row2 = $db->Row()
{
echo "Something";
}

  2. Re: multiple queries   Reply   Report abuse  
Picture of DENIS CARON DENIS CARON - 2014-09-06 08:17:51 - In reply to message 1 from Chris Beech
Hi,

You cannot do like that.

If your Queries returns only one row, run like this:

$row1 = $db->QuerySingleRow($sql1);
$row2 = $db->QuerySingleRow($sql2);


If your Queries returns multiple rows, you must use results before next queries... And don't forget to test if queries return TRUE !

$result1 = $db->Query($sql1);
if($result1) while($row1 = $db->Row()
{
echo "Something";
}

$result2 = $db->Query($sql2);
if($result2) while($row2 = $db->Row()
{
echo "Something";
}