Algo así, pero tendrías que sobreescribir el método que quieras, por ejemplo:
Código PHP:
Ver original<?php
class CountPDO extends PDO
{
private $_queryCount = 0;
public function query()
{
$this->_increaseQueryCount();
case 1:
return parent::query($args[0]);
break;
case 2:
throw new Exception('Invalid number of arguments');
break;
case 3:
return parent::query($args[0], $args[1], $args[2]);
break;
case 4:
return parent::query($args[0], $args[1], $args[2], $args[3]);
break;
}
}
public function prepare
($statement, $driver_options = array()) {
$this->_increaseQueryCount();
return parent::prepare($statement, $driver_options);
}
private function _increaseQueryCount()
{
$this->_queryCount++;
}
public function getQueryCount()
{
return $this->_queryCount;
}
}
Saludos.