dongtun3328 2014-04-23 11:59
浏览 56

ZF2和SQL服务器'以用户身份执行'

Currently we are running Zend Framework 2 and SQL server for our internal application. We have a stored procedure in place for our AuditTrail. This AuditTrail include a AuditUser who made the change/insert. At this moment this "AuditUser" is username of PDO connection.

We are working towards a situation to change this AuditUser is the active user who made the change and would like to use EXECUTE as USER='[REALUSER]'. And their strange behaviour starts. When executing this statement, everything is doing fine. But when I refresh the page, SQL server returns following errors:

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: [Microsoft][SQL Server Native Client 11.0]Unspecified error occurred on SQL Server. Connection may have been terminated by the server.'

Zend\Db\Adapter\Exception\InvalidQueryException: Statement could not be executed (08S01233 - [Microsoft][SQL Server Native Client 11.0]Shared Memory Provider: No process is on the other end of the pipe.

And after refreshing again, it's executing fine again.

I think it has something todo with session from SQL/PDO(http://msdn.microsoft.com/en-us/library/ms181362.aspx, says session is switched). But I'm unable to resolve this issue. Could somebody help or suggest a way forward?

Regards,

Pim

  • 写回答

1条回答 默认 最新

  • duanoucuo7045 2017-11-21 23:43
    关注

    For those of you who experienced the same problem - this link helped me: https://blogs.msdn.microsoft.com/brian_swan/2010/11/17/sql-server-driver-for-php-connection-options-connection-pooling/

    If you are using sqlsrv function, as I am, the only thing you need to do is setting ConnectionPooling to false, as described in given link:

    e.g. $options = array("Database"=>"master", "UID"=>"user", "PWD"=>"password", "ConnectionPooling"=>0);

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思