Ver Mensaje Individual
  #11 (permalink)  
Antiguo 10/05/2010, 13:48
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Numero de consultas realizas script con PDO

Algo así, pero tendrías que sobreescribir el método que quieras, por ejemplo:
Código PHP:
Ver original
  1. <?php
  2. class CountPDO extends PDO
  3. {
  4.     private $_queryCount = 0;
  5.    
  6.     public function query()
  7.     {
  8.         $this->_increaseQueryCount();
  9.         $args = func_get_args();
  10.         switch(func_num_args()) {
  11.             case 1:
  12.                 return parent::query($args[0]);
  13.                 break;
  14.             case 2:
  15.                 throw new Exception('Invalid number of arguments');
  16.                 break;
  17.             case 3:
  18.                 return parent::query($args[0], $args[1], $args[2]);
  19.                 break;
  20.             case 4:
  21.                 return parent::query($args[0], $args[1], $args[2], $args[3]);
  22.                 break;
  23.         }
  24.     }
  25.    
  26.     public function prepare($statement, $driver_options = array())
  27.     {
  28.         $this->_increaseQueryCount();
  29.        
  30.         return parent::prepare($statement, $driver_options);
  31.     }
  32.    
  33.     private function _increaseQueryCount()
  34.     {
  35.         $this->_queryCount++;
  36.     }
  37.    
  38.     public function getQueryCount()
  39.     {
  40.         return $this->_queryCount;
  41.     }
  42. }

Saludos.