准备好的声明是否会对文本进行干

UPDATE: I think I'm facing this issue http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/2a559a42-0ef3-42c8-9e87-08ff7934678a/ will come back shortly, if this is the case.

I cannot understand what's happening. Maybe the debugging tools are bad, or something is broken in the way statements are assembled, anyway, would love to have some hints / perhaps an alternative way to handle the problem.

I have this statement:

$rule_statment = $pdo->prepare(
                "if not exists
                 (select * from menu_availability_rules
                 where
                   (daily_serving_start = :start or
                    daily_serving_start is null and :start is null) and
                   (daily_serving_end = :end or
                    daily_serving_end is null and :end is null) and
                   (weekly_service_off = :weekly or
                    weekly_service_off is null and :weekly is null) and
                   (one_time_service_off = :once or
                    one_time_service_off is null and :once is null))
                 begin
                   insert into menu_availability_rules
                    (daily_serving_start, daily_serving_end,
                     weekly_service_off, one_time_service_off)
                   values (:start, :end, :weekly, :once)
                 end");

I bind all necessary parameters before calling execute, but I get a syntax error in return from SQL Server:

COUNT field incorrect or syntax error

I tried printing out:

$rule_statment->debugDumpParams();

And the output is this:

if not exists
                 (select * from menu_availability_rules
                 where
                   (daily_serving_start = :start or
                    daily_serving_start is null and :start is null) and
                   (daily_serving_end = :end or
                    daily_serving_end is null and :end is null) and
                   (weekly_service_off = :weekly or
                    weekly_service_off is null and :weekly is null) and

Params:  4
Key: Name: [6] :start
paramno=0
name=[6] ":start"
is_param=1
param_type=0
Key: Name: [4] :end
paramno=2
name=[4] ":end"
is_param=1
param_type=0
Key: Name: [7] :weekly
paramno=4
name=[7] ":weekly"
is_param=1
param_type=1
Key: Name: [5] :once
paramno=6
name=[5] ":once"
is_param=1
param_type=2

Why? What exactly happened?

It appears that PHP will not replace named parameters, if they appear multiple times int the query - who knew :|