dqsot35145 2013-03-10 10:20
浏览 35

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

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?

  • 写回答

1条回答 默认 最新

  • duankuang1046 2013-03-10 10:37
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致