PDOException SQLSTATE [IMSSP]有一个带有挂起结果的语句

时间:2015-08-31 09:47:26

标签: php doctrine

使用的技术:

DOCTRINE 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驱动程序。

当我查询数据库时发生错误。 与数据库的连接是可以的。当我使用方法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:694Stack:

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 个答案:

答案 0 :(得分:0)

  1. 首先尝试重启apache和SQL服务器。

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

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