mOrloff
03-18-2010, 07:32 PM
I am trying to compare a dataset from an MSSQL query to some MySQL data.
(This is all on a local machine which is both an MSSQL Server and a WAMP server.)
When I comment out all the stuff which pertains to running the MySQL query (as shown in the code included below), I get a total of 7218 rows returned.
As soon as I uncomment the $result=$fchzConn->query($fchzSQL); line, my resultset drops down to about 150 records.
What am I missing ??
Here's the applicable code: (I try to comment like a madman to make review easier)
//while($keepGoing){ // REM'd during production/testing
$j=$k=0; while($k<3){ $k++; // for testing
if($lastIteration) $keepGoing=false; // we've reached stopping point for the WHILE($keepGoing) loop
$rzSQL="SELECT fullpartnumber AS pn,description,lowprice,price,quantity AS qty FROM partrecord WHERE quantity>$qtyBottom AND quantity<=$qtyTop"; // sql
$rzStock=sqlsrv_query($rzConn,$rzSQL); // run the query
if(!$rzStock){echo 'Error in statement execution.\n'; die( print_r( sqlsrv_errors(), true));
}else{
$i=0; // for testing
while($row=sqlsrv_fetch_array($rzStock, SQLSRV_FETCH_ASSOC)){ // use "sqlsrv_fetch_array($rzStock)" for regular array
$i++; $j++; echo "$j) Group $k : Row $i (top qty = $qtyTop)"; // for testing
$stockPN=$row['pn']; // grab the part number
$fchzSQL="SELECT pn,description FROM future WHERE pn=\"$stockPN\"";
echo $fchzSQL.'<br/>'; // for testing
// $result=$fchzConn->query($fchzSQL);
// if(!$result){
// echo " - No match found for $stockPN.<br/>"; // for testing
// }else{
// $array=$fchzConn->fetch_array($result);
// echo '<pre>'; print_r($array); echo '</pre>'; // for testing
// }
} // end WHILE($row...) loop
$qtyBottom=$qtyTop; // set the new bottom qty to pick up where the last loop left off
if($qtyTop>=100000){ // increment the top qty for paginating the query
$qtyTop=floor($qtyTop*1.5);
}elseif($qtyTop>=10000){
$qtyTop+=10000;
}elseif($qtyTop>=1000){
$qtyTop+=1000;
}elseif($qtyTop>=100){
$qtyTop+=100;
}elseif($qtyTop>=50){
$qtyTop+=10;
}elseif($qtyTop>=10){
$qtyTop+=5;
}else{
$qtyTop++;
} // end IF/ELSEIF($qtyTop>=...) conditionals
if($qtyTop>=$qtyMax){
$lastIteration=true; // the next loop will be the last one
$qtyTop=$qtyMax; // don't overshoot
} // end IF($qtyTop>=...) conditional
} // end WHILE($keepGoing) loop
NOTE: I did look in the query method in the DB class, and I don't see anything that would limit it from that side. If you would like to see it anyhow, just let me know.
Thanks-a-bunch,
~ Mo
(This is all on a local machine which is both an MSSQL Server and a WAMP server.)
When I comment out all the stuff which pertains to running the MySQL query (as shown in the code included below), I get a total of 7218 rows returned.
As soon as I uncomment the $result=$fchzConn->query($fchzSQL); line, my resultset drops down to about 150 records.
What am I missing ??
Here's the applicable code: (I try to comment like a madman to make review easier)
//while($keepGoing){ // REM'd during production/testing
$j=$k=0; while($k<3){ $k++; // for testing
if($lastIteration) $keepGoing=false; // we've reached stopping point for the WHILE($keepGoing) loop
$rzSQL="SELECT fullpartnumber AS pn,description,lowprice,price,quantity AS qty FROM partrecord WHERE quantity>$qtyBottom AND quantity<=$qtyTop"; // sql
$rzStock=sqlsrv_query($rzConn,$rzSQL); // run the query
if(!$rzStock){echo 'Error in statement execution.\n'; die( print_r( sqlsrv_errors(), true));
}else{
$i=0; // for testing
while($row=sqlsrv_fetch_array($rzStock, SQLSRV_FETCH_ASSOC)){ // use "sqlsrv_fetch_array($rzStock)" for regular array
$i++; $j++; echo "$j) Group $k : Row $i (top qty = $qtyTop)"; // for testing
$stockPN=$row['pn']; // grab the part number
$fchzSQL="SELECT pn,description FROM future WHERE pn=\"$stockPN\"";
echo $fchzSQL.'<br/>'; // for testing
// $result=$fchzConn->query($fchzSQL);
// if(!$result){
// echo " - No match found for $stockPN.<br/>"; // for testing
// }else{
// $array=$fchzConn->fetch_array($result);
// echo '<pre>'; print_r($array); echo '</pre>'; // for testing
// }
} // end WHILE($row...) loop
$qtyBottom=$qtyTop; // set the new bottom qty to pick up where the last loop left off
if($qtyTop>=100000){ // increment the top qty for paginating the query
$qtyTop=floor($qtyTop*1.5);
}elseif($qtyTop>=10000){
$qtyTop+=10000;
}elseif($qtyTop>=1000){
$qtyTop+=1000;
}elseif($qtyTop>=100){
$qtyTop+=100;
}elseif($qtyTop>=50){
$qtyTop+=10;
}elseif($qtyTop>=10){
$qtyTop+=5;
}else{
$qtyTop++;
} // end IF/ELSEIF($qtyTop>=...) conditionals
if($qtyTop>=$qtyMax){
$lastIteration=true; // the next loop will be the last one
$qtyTop=$qtyMax; // don't overshoot
} // end IF($qtyTop>=...) conditional
} // end WHILE($keepGoing) loop
NOTE: I did look in the query method in the DB class, and I don't see anything that would limit it from that side. If you would like to see it anyhow, just let me know.
Thanks-a-bunch,
~ Mo