FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PDO fetch with SQL server
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Return to the default flat view Create a new topic Submit Reply
PDO fetch with SQL server [message #186301] Mon, 23 June 2014 11:02 Go to previous message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma:
Junior Member
add to buddy list
ignore all messages by this user
I have a strange case. I have a query in SQL server that has in the
beginning to determine the action:

SELECT
CASE
WHEN x.NEW_HASH = x.PREVIOUS_HASH THEN 'SAME'
WHEN x.NEW_HASH != x.PREVIOUS_HASH AND
x.PREVIOUS_HASH IS NOT NULL AND x.[KEY] IS NOT NULL THEN 'UPDATE'
WHEN x.PREVIOUS_HASH IS NULL AND
x.count_of_tracking_records > 0 THEN 'UPDATE'
WHEN x.PREVIOUS_HASH IS NULL THEN 'INSERT'
WHEN x.[KEY] IS NULL THEN 'DELETE'
ELSE 'UNKNOWN'
END AS ACTION,
x.*

so that it will choose the action. There is a FULL OUTER JOIN at the
end to the destination table. Another, later, query, will do a merge
and perform the action specified in the results of this query.

The PHP function that this uses is a PDO statement with the fetch method
and the PDO::FETCH_ASSOC as the parameter.

When this query is run against an empty destination table, 1991 records
are obtained which are subsequently inserted into the destination table
by the second query.

When this same query is then run against this filled table, with the
same records, the PDO fetch retrieves zero records. I have put in log
files into the PHP code and it is clear that the fetch returns zero
records.

However, when this query is cut and pasted into Sqlserver Management
Studio and run, it produces 3982 records. The first 1981 are with
action DELETE and the rest are with action INSERT.

One additional point that might, or might not, have a bearing on this.
Some variables have bindings. For example a :grouping_1 has a string
value that is the same for the entire query. When I run it in Sqlserver
Management Studio I replace those bind variable with their values.

Crossposted to both the php and sqlserver news groups.

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: is possible with own mail server have same results of mailchimp?
Next Topic: str_replace does not like empty quotes
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 17 03:04:33 EST 2017

Total time taken to generate the page: 0.00710 seconds