So, I've had this problem before and never solved it but now I got it again and I really want it to be solved.
In a PHP file I execute the following lines:
The problem is in the querySelect() which you can see down below..
$stmt = sqlsrv_query($dbconn, "SELECT * FROM USERS");
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC );
Logger::logg("ROW (not in method): " . var_export($row, true), LV);
querySelect("SELECT * FROM USERS",$dbconn);
And I get the following: (The first output is correct and selects the first user and as you can see returns an associcative array). Then in querySelect $row is true each time. (there is more outputs of this because it does it for each user ofcourse...)
07/25/12 12:11:26 - ROW (not in method): array (
'LopNr' => 1,
'Mail' => 'xxxx ',
'Password' => 'xxx',
'Auth' => '1',
'DisplayName' => 'xxx ',
'sdsd' => xx,
'sdsd' => 'xxx',
'ts' => 1342093599,
'Cell' => NULL,
'WantsSMS' => xxx,
).
07/25/12 12:11:27 - Query: SELECT * FROM USERS.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
07/25/12 12:11:27 - ROW: true.
querySelect is implemented like this:
function querySelect($query, $dbconn, $fetchLimit = 1000000)
{
$stmt = sqlsrv_query($dbconn, $query);
Logger::logg(LOGG_QRY_ERR_VERBOSE . $query, LV);
if ( !$stmt )
{
Logger::logg(LOGG_QRY_ERR);
throw new Exception(ERR_QUERY);
}
$resultArray = array();
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC ) && $fetchLimit > 0)
{
Logger::logg("ROW: " . var_export($row, true), LV);
$resultArray[] = $row;
$fetchLimit--;
}
return $resultArray;
}