daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Apr 29th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     class PDOp {
  2.         protected $PDO;
  3.         public $numExecutes;
  4.         public $numStatements;
  5.         public function __construct($dsn, $user=NULL, $pass=NULL, $driver_options=NULL) {
  6.             $this->PDO = new PDO($dsn, $user, $pass, $driver_options);
  7.             $this->numExecutes = 0;
  8.             $this->numStatements = 0;
  9.         }
  10.         public function __call($func, $args) {
  11.             return call_user_func_array(array(&$this->PDO, $func), $args);
  12.         }
  13.         public function prepare() {
  14.             $this->numStatements++;
  15.            
  16.             $args = func_get_args();
  17.             $PDOS = call_user_func_array(array(&$this->PDO, 'prepare'), $args);
  18.            
  19.             return new PDOpStatement($this, $PDOS);
  20.         }
  21.         public function query() {
  22.             $this->numExecutes++;
  23.             $this->numStatements++;
  24.            
  25.             $args = func_get_args();
  26.             $PDOS = call_user_func_array(array(&$this->PDO, 'query'), $args);
  27.            
  28.             return new PDOpStatement($this, $PDOS);
  29.         }
  30.         public function exec() {
  31.             $this->numExecutes++;
  32.            
  33.             $args = func_get_args();
  34.             return call_user_func_array(array(&$this->PDO, 'exec'), $args);
  35.         }
  36.     }
  37.     class PDOpStatement implements IteratorAggregate {
  38.         protected $PDOS;
  39.         protected $PDOp;
  40.         public function __construct($PDOp, $PDOS) {
  41.             $this->PDOp = $PDOp;
  42.             $this->PDOS = $PDOS;
  43.         }
  44.         public function __call($func, $args) {
  45.             return call_user_func_array(array(&$this->PDOS, $func), $args);
  46.         }
  47.         public function bindColumn($column, &$param, $type=NULL) {
  48.             if ($type === NULL)
  49.                 $this->PDOS->bindColumn($column, $param);
  50.             else
  51.                 $this->PDOS->bindColumn($column, $param, $type);
  52.         }
  53.         public function bindParam($column, &$param, $type=NULL) {
  54.             if ($type === NULL)
  55.                 $this->PDOS->bindParam($column, $param);
  56.             else
  57.                 $this->PDOS->bindParam($column, $param, $type);
  58.         }
  59.         public function execute() {
  60.             $this->PDOp->numExecutes++;
  61.             $args = func_get_args();
  62.             return call_user_func_array(array(&$this->PDOS, 'execute'), $args);
  63.         }
  64.         public function __get($property) {
  65.             return $this->PDOS->$property;
  66.         }
  67.         public function getIterator() {
  68.             return $this->PDOS;
  69.         }
  70.    }
  71. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top