wierd sql issue
Posted: Tue Oct 24, 2006 2:48 pm
So I posted a question about this a while back and have been using this method ever since, but today I ran into a strange issue.
This involves mssql_query function and evaluating the results. Normally I do it as such:
According to the php.net manual this should and has been working:
Today I came across a result that was not in the database so it returned 0 rows. But it did have a resource id so was evlauated as data.
Here is a print out of the number of rows and the queries that were executed.
Any ideas? I expected for the num rows =0 to return a TRUE instead they returned a resource id?
This involves mssql_query function and evaluating the results. Normally I do it as such:
Code: Select all
if ($result === false)
{
// error
}
elseif ($result === true)
{
// no rows
}
else
{
// you have rows
}Returns: A MS SQL result resource on success, TRUE if no rows were returned, or FALSE on error.
Today I came across a result that was not in the database so it returned 0 rows. But it did have a resource id so was evlauated as data.
Here is a print out of the number of rows and the queries that were executed.
Code: Select all
query Resource id #5 = SELECT Name FROM Computer WHERE (Name = 'FSILBIT201') AND (idComputer NOT IN (SELECT idComputer FROM computerMaintenance WHERE InMaintenanceNow = '1')) -- num rows =1
query Resource id #6 = SELECT Name FROM Computer WHERE (Name = 'FSILHFTR01') AND (idComputer NOT IN (SELECT idComputer FROM computerMaintenance WHERE InMaintenanceNow = '1')) -- num rows =1
query Resource id #7 = SELECT Name FROM Computer WHERE (Name = 'GOORCACCAPP1') AND (idComputer NOT IN (SELECT idComputer FROM computerMaintenance WHERE InMaintenanceNow = '1')) -- num rows =0