I am trying to identify a problem using PDO through an ODBC connection to a SQL Server database, where I get an empty result set for a known good query. I would appreciate any community recommendations. This is part of a large system that I have been working on for about five years; it takes the XML representation of the report, generates SQL from it, launches the query, formats the result set on demand and creates a web page for presentation. More than you probably needed to know, but I'm trying to convey that I understand a lot how this should work, and in most cases it works reliably. But I have a client who wanted something new, and he broke my system.
I see this as a well-known good query in the sense that I can copy and paste the query from my log file into SSMS (SQL Server Console) and run it. He gives 62 series of results. But when I run the same query through PDO, I return PDOStatement, no errorInfo(), no exceptions, etc. But it fetchAll()returns an empty array. Initially I used query(), but it would be safer to use prepare(), and execute()if the request was something that I had not noticed. It didn’t matter.
I understand that type conversion problems may occur, but in the example below, the two extracted fields are of type nvarchar (128) and nvarchar (32), respectively, which successfully return with other requests.
I should mention that the request is executed exactly once in the application, so this is not a question of any previous execution that interferes with the next, as far as I can tell. In addition, the PDO has setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION);
Here's the PDOStatement returned by execute ():
Result Set PDOStatement Object
(
[queryString] => SELECT [dbo].[Supplier].[SupplierName] AS suppliername,[dbo].[Item].[ItemLookupCode] AS itemlookupcode FROM [dbo].[Order] LEFT JOIN [dbo].[OrderEntry] ON [dbo].[Order].ID=[dbo].[OrderEntry].OrderID LEFT JOIN [dbo].[Item] ON [dbo].[Item].ID=[dbo].[OrderEntry].ItemID,[dbo].[Supplier] WHERE ([dbo].[Order].Time >= '2015-01-01 00:00:00') AND ([dbo].[Order].Time <= '2015-03-31 23:59:59') AND ([dbo].[Item].SupplierID=[dbo].[Supplier].ID) ORDER BY [dbo].[Supplier].[SupplierName]
)
It's not that complicated, and other SQL queries work fine with this database. There's just something about it that crashes through PDO, but works inside SSMS.
Any ideas? Has anyone seen this behavior before? Is there any other way to see what is happening here? I examined a few questions on this topic, but they all seem to be something wrong, that I do not.
PHP 5.4.22, by the way.