Ver Mensaje Individual
  #6 (permalink)  
Antiguo 27/01/2011, 15:12
Avatar de Drknow
Drknow
 
Fecha de Ingreso: febrero-2008
Mensajes: 121
Antigüedad: 16 años, 2 meses
Puntos: 1
Pregunta Respuesta: Fatal error: limpiar buffer de consulta PDO

aun estoy en las mismas lo he dejado pero ahora quiero que salga pero aun nada...

como limpio el buffer de consulta pues estoy usando un singleton y en la misma pagina hago 3 consultas, todo sale ok pero al final de la pagina me imprime este error el apache, al ultimo hago un insertInto de auditoria pues este no se llega a ejecutar

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in C:\www\webs\GestRecHuman\persistencia\OperacionDAO MySQL.php:54 Stack trace: #0 C:\www\webs\GestRecHuman\persistencia\OperacionDAO MySQL.php(54): PDOStatement->execute() #1 C:\www\webs\GestRecHuman\dominio\OperacionService. php(36): OperacionDAOMySQL->insertOperacion(Object(Operacion)) #2 C:\www\webs\GestRecHuman\dominio\OperacionFacade.p hp(64): OperacionService->insertOperacion(Object(Operacion)) #3 C:\www\webs\GestRecHuman\presentacion\VistaEmplead o.php(85): OperacionFacade::guardarOperacion(Object(Operacion )) #4 C:\www\webs\GestRecHuman\presentacion\VistaEmplead o.php(88): VistaEmpleado::main() #5 {main} thrown in C:\www\webs\GestRecHuman\persistencia\OperacionDAO MySQL.php on line 54



Código PHP:

    
public function insertOperacion(Operacion $operacion)
    {
        
$flag FALSE;
    
$query 'CALL SPinsertOperacion(?, ?, ?, ?, ?, ?)';
    try {
            
$cn ConnectionManager::getInstance();
           
// $cn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY , true);
            
$st $cn->prepare($query);
            
$st->bindParam(1$operacion->getIdOperacion());
            
$st->bindParam(2$operacion->getQuery());
            
$st->bindParam(3$operacion->getTable());
            
$st->bindParam(4$operacion->getOperationDate());
            
$st->bindParam(5$operacion->getIdUser());
            
$st->bindParam(6$operacion->getUserIdUser());
            
$st->execute(); /* linea 54 */
            
$flag TRUE;
            
$st NULL;
            
$cn NULL;
    } catch (
PDOException $ex) {
            throw 
$ex;
    }
            return 
$flag;

    } 

no se si se puede tener mas de un setAttribute en la conexion

Código PHP:
// es un singleton
    
public static function getInstance()
    {
       if (
self::$_instance == null) {

            try {
            
self::$_instance = new PDO(self::$_urlself::$_userself::$_password);
                
self::$_instance->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
           
                
self::$_instance->setAttribute(PDO::ATTR_CASEPDO::CASE_LOWER);
                         
self::$_instance->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);

                        } catch (
PDOException $ex) {
                
self::$_instance null;
                throw 
$ex;
            }
        }

           return 
self::$_instance;
    }