Ver Mensaje Individual
  #21 (permalink)  
Antiguo 10/05/2010, 23:35
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

Cita:
Iniciado por abimaelrc Ver Mensaje
Es verdad que en el manual viene explicado con solo esos tres ejemplos, pero buscando así por internet otros ejemplos encontré que sí se puede enviar con solo dos argumentos
Código PHP:
Ver original
  1. <?php
  2. $row = $db->query('SELECT symbol,planet FROM zodiac',PDO::FETCH_BOUND);
Así como te expuse en el ejemplo.
En ese caso podríamos simplificar la clase así:
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.        
  11.         return call_user_func_array(array('parent', 'query'), $args);
  12.     }
  13.    
  14.     public function prepare($statement, $driver_options = array())
  15.     {
  16.         $this->_increaseQueryCount();
  17.         return parent::prepare($statement, $driver_options);
  18.     }
  19.    
  20.     private function _increaseQueryCount()
  21.     {
  22.         $this->_queryCount++;
  23.     }
  24.    
  25.     public function getQueryCount()
  26.     {
  27.         return $this->_queryCount;
  28.     }
  29. }

@neodani, que bueno que entendiste para que sirve heredar las clases.

Saludos.