PDOException SQLSTATE[IMSSP]存在一个挂起结果的语句


PDOException SQLSTATE[IMSSP] there is a statement with pending results

使用技术:

2.4学说。*/PHP 5.3.0/SQL server 2000/XAMPP是1.7.2

SQL Server 2000安装在Windows 2003 Server.

这个web应用程序在XAMMP和windows 7 32位的计算机上。

连接到数据库sql server 2000我需要驱动程序sqlsrv2.0和安装windows 2008本地客户端32位。为此,我在文件php.ini中添加:

extension=php_sqlsrv_53_ts_vc9.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll

现在,当我运行phpinfo()显示sqlsrv pdo drivers.

在查询数据库时出现错误。与数据库的连接正常。当我使用find()或findAll()方法时,它可以工作。

citas.php:

<?php
require_once "../doctrine/bootstrap.php";
$query = $entityManager->createQuery('SELECT c FROM Cita c WHERE (c.CodigoCita>?1)');
$query->setParameter(1,100);
$citas = $query->getResult();
echo count($citas);
错误:

br />
    <b>Fatal error</b>:  Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: 
    The connection cannot process this operation because there is a statement with pending results.  
    To make the connection available for other queries, either fetch all results or cancel or free the statement.  
    For more information, see the product documentation about the MultipleActiveResultSets connection option.' 
    in C:'xampp'htdocs'HistoriaRedonda'doctrine'vendor'doctrine'dbal'lib'Doctrine'DBAL'Connection.php:694
    Stack 
    trace:
    #0 C:'xampp'htdocs'HistoriaRedonda'doctrine'vendor'doctrine'dbal'lib'Doctrine'DBAL'Connection.php(694): PDOStatement-&gt;execute()
    #1 C:'xampp'htdocs'HistoriaRedonda'doctrine'vendor'doctrine'orm'lib'Doctrine'ORM'Persisters'BasicEntityPersister.php(748): Doctrine'DBAL'Connection-&gt;executeQuery('SELECT t0.Codig...', Array, Array)
    #2 C:'xampp'htdocs'HistoriaRedonda'doctrine'vendor'doctrine'orm'lib'Doctrine'ORM'Persisters'BasicEntityPersister.php(829): Doctrine'ORM'Persisters'BasicEntityPersister-&gt;load(Array, NULL, Array)
    #3 C:'xam in <b>C:'xampp'htdocs'HistoriaRedonda'doctrine'vendor'doctrine'dbal'lib'Doctrine'DBAL'DBALException.php</b> on line <b>91</b><br />

Connection.php: 694栈:

public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
    {
        if ($qcp !== null) {
            return $this->executeCacheQuery($query, $params, $types, $qcp);
        }
        $this->connect();
        $logger = $this->_config->getSQLLogger();
        if ($logger) {
            $logger->startQuery($query, $params, $types);
        }
        try {
            if ($params) {
                list($query, $params, $types) = SQLParserUtils::expandListParameters($query, $params, $types);
                $stmt = $this->_conn->prepare($query);
                if ($types) {
                    $this->_bindTypedValues($stmt, $params, $types);
line 694                   $stmt->execute();

                } else {
                    $stmt->execute($params);
                }
            } else {
                $stmt = $this->_conn->query($query);
            }
        } catch ('Exception $ex) {
            throw DBALException::driverExceptionDuringQuery($ex, $query, $this->resolveParams($params, $types));
        }
        $stmt->setFetchMode($this->defaultFetchMode);
        if ($logger) {
            $logger->stopQuery();
        }
        return $stmt;
    }

bootstrap.php:

<?php header('Content-Type: text/html; charset=UTF-8');
use Doctrine'ORM'Tools'Setup;
use Doctrine'ORM'EntityManager;
require_once 'vendor/autoload.php';

$isDevMode = true;
$conn = array(
    'driver'   => 'pdo_sqlsrv',
    'host'     => '192.168.1.6',
    'dbname'   => 'MedicosCopia272015',
    'user'     => 'XXX',
    'password' => 'XXXXXXXXXX',
    'MultipleActiveResultSets' => false
);
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
$entityManager = EntityManager::create($conn, $config);
  1. 首先尝试重新启动apache和SQL服务器。

  2. 检查SQL查询是否正确配置了PDO。

  3. 一个或多个PDO进程暂停或不正确关闭。请找到并杀死所有的PDO进程。使用ps aux | grep "someprocess"查找正在运行的PDO进程,使用pkill -p processid杀死正在运行的PDO进程。