0

Okay this is weird to me, but I'm hoping this is an issue that's happened and I have just not found the solution online yet.

Help is very much appreciated.

I am doing a call to a stored procedure on a MS 2008 SQL server. Using SQL Server Management studio, we can verify that this procedure is working correctly.

I wrote a basic script which grabs each row and does a print_r of it.

Now for the weird part. For any row that has a NULL entry (even just one column), PHP simply does not get it, the row is left out, for all others they come in just fine. So if I go back in and manually change the NULL entries and just put text there, they show up.

So basically, this one column that I have which is allowed to be NULL, when it is NULL nothing comes up data wise for that row (it's left out) in PHP. But if you then go in and manually add something it shows up no problem.

According to phpinfo the connector I am using is Free TDS.

user1399840
  • 53
  • 1
  • 8
  • You want PHP to give you an invented value for a row that is null? What are you expecting it to print? – Jesse Schoff Mar 13 '13 at 00:15
  • No sorry, the row isn't null, the row has values in it. Just one of the columns in this row is null and because of that I get nothing returned. So let's say I have 5 rows, all rows have data except row 2 has one column that is null. What happens on PHP is I only get 4 rows returned. – user1399840 Mar 13 '13 at 16:52

1 Answers1

0

This what fixed it for me:

set ANSI_NULL_DFLT_ON ON

I had to query this first before calling any stored procedures

$result = mssql_query('set ANSI_NULL_DFLT_ON ON');

Hope that helps for anyone who had my problem. It was really frustrating, apparently you need this so PHP will return rows that have null columns in it and it has something to do with a compare inside the stored procedure. I believe it's when comparing something that might have a NULL value, PHP will ignore the entire row unless you pass this first.

user1399840
  • 53
  • 1
  • 8