dpjhq00684 2019-01-03 07:43
浏览 23

too long

I am working on a Symfony 4 project with a MSSQL server (not optimal no, but corporate decision).

We are experiencing an issue when we use named variables.

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near ':'.

ex:

$query->where("status = :status");

we apply the values with setParameter()

$query->setParameter('status', $status);

We receive a syntax error. I have attempted to store quotes with the variable itself to make sure that is not the case, however it returns the same error. If I replace the named variables with ex: 'ACTIVE' it works as expected. I have also printed the sql with getSQL() and tested this directly in SQL Management Studio, this works fine also.

Debugging the statement is rough, and I am considering if we need to make a connection wrapper class and manipulate in order to support MSSQL, but before going to that extend, maybe some of you guys have an idea?

Full error response:

An exception occurred while executing 'SELECT U.CIID AS ciid, U.USERID as userid, U.FIRSTNAME as firstname, U.MIDDLENAME as middlename, U.LASTNAME as lastname, ACI.emailid as email, U.JOBTITLE as position, ACI.landline as phone_local, ACI.mobile as phone_mobile, P.ATTRIBUTE_1801 as phone_cisco FROM SDUSER U INNER JOIN AaaUser AU ON U.USERID=AU.USER_ID INNER JOIN People P ON U.CIID=P.CIID INNER JOIN AaaUserContactInfo AUCI ON AU.USER_ID=AUCI.USER_ID INNER JOIN AaaContactInfo ACI ON AUCI.CONTACTINFO_ID=ACI.CONTACTINFO_ID WHERE U.STATUS=:status':

SQLSTATE [42000, 102]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near ':'.
SQLSTATE [42000, 8180]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (500 Internal Server Error)

As you can see, it looks like the named parameters is forcing a wrap of quotes of the entire sql that mssql cannot accept.

MSSQL 2012 PHP 7.1.3 Symfony 4 Doctrine 2

  • 写回答

1条回答 默认 最新

  • dtid30526 2019-01-03 08:31
    关注

    May be you need to put this code below:

    ini_set('mssql.charset', 'UTF-8');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀