2014-10-16 10:24

游标状态无效 - pdo_odbc FreeTDS SQL Server


We're running a completely nonchalant query and are getting the following error:

PDOException : SQLSTATE[24000]: Invalid cursor state: 0 [FreeTDS][SQL Server]Invalid cursor state (SQLExecute[0] at /builddir/build/BUILD/php-5.5.13/ext/pdo_odbc/odbc_stmt.c:254)

From PHP we're using the pdo_odbc library to connect via FreeTDS to SQLServer 2008

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douyue1926 douyue1926 7年前

    It transpires that it was the preceding query that was causing problems. We were using:


    to get out a single row but not doing anything with it after then. This was leaving a cursor open which was then throwing the error then next time any query was executed. For us, closing the cursor before the next query was the way forward.


    It's also worth noting that using fetchAll() (in the preceding query) is also a fix as this does not leave a cursor open.

    点赞 评论 复制链接分享