2012-11-08 4 views
3

Doctrine2를 사용하여 응용 프로그램을 작성했습니다. Doctrine2는 MySQL 또는 Postgres 데이터베이스와 함께 사용할 때 유용합니다.Doctrine 및 MS SQL 2008의 SELECT 문제

PDO Driver DBLib을 사용하여 응용 프로그램을 SQL Server 및 Sybase에서 공유하는 TDS (테이블 형식 데이터 스트림 프로토콜) 용 FreeTDS 구현을 사용하여 SQL Server 2008 데이터베이스와 연결했습니다.

Doctrine SQLServerPlatform 및 MSSQL 드라이버 패키지의 일부 조정 후 초기 스키마 생성, 트랜잭션 및 INSERT이 정상적으로 작동합니다. 선택 데이터, 우리는 다음과 같은 오류에 직면 할 때

는하지만 :

If you are accustomed to programming with other database servers, you may be surprised when you first encounter this aspect of the TDS protocol. [...]

The server requires the client either to read all the results from a query, or to indicate that no further rows are desired i.e., to issue a cancellation. Until one of those two things happens, the server will not accept new queries on that connection. It will complain about "pending results".

그래서 오류 메시지의 원인은 몇 가지 이유 때문이다 : 인터넷 검색을 많이 후

General error: 20019 Attempt to initiate a new Adaptive Server operation with results pending 

을 나는 this detail in the FAQ of FreeTDS 발견 Doctrine (DBAL-> PDO-> FreeTDS)은 연결 버퍼에서 모든 결과 행을 읽지 않았으며 서버/라이브러리는 응용 프로그램이 모든 행을 읽을 때까지 새로운 exec()/execute()을 발행하도록 허용하지 않습니다.

  • 반환하기 전에 $doctrinequery->getResults()은 모든 결과를 가져옵니다.
  • 반환하기 전에 $entity->getLinkedEntity() (즉, $user->getGroupNames())이 모든 결과를 가져 오는 것으로 이해합니까?
  • 정확하게 문제가 발생한 곳을 어떻게 처리 하시겠습니까?
    스택 트레이스 (stacktraces)가 전혀 도움이되지 않고 코드베이스가 이미 커졌습니다.
  • 다른 사람이 이미이 문제가있어 통찰력을 공유 할 수 있습니까?
  • 이 문제가 발생하지 않는 Doctrine을 MSSQL에 연결할 수있는 대안이 있습니까?

답변

1

PDO 드라이버 DBLib 및 트랜잭션과 비슷한 문제가있었습니다. http://php.net/manual/en/pdostatement.closecursor.php

:
$this->_db->beginTransaction(); 

$st = $this->_db->prepare("StoredProcedure ?"); 
$st->execute(array($data)); 
$results= $st->fetchAll(); 
$st->closeCursor(); 

// more stuff 

$this->_db->commit(); 

closeCursor()

내 문제를 해결 : 나는 이런 식으로 고정