daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Apr 29th, 2017 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     //java сосёт
  4.  
  5.  
  6.     class PDOp {
  7.         protected $PDO;
  8.         public $numExecutes;
  9.         public $numStatements;
  10.         public function __construct($dsn, $user=NULL, $pass=NULL, $driver_options=NULL) {
  11.             $this->PDO = new PDO($dsn, $user, $pass, $driver_options);
  12.             $this->numExecutes = 0;
  13.             $this->numStatements = 0;
  14.         }
  15.         public function __call($func, $args) {
  16.             return call_user_func_array(array(&$this->PDO, $func), $args);
  17.         }
  18.         public function prepare() {
  19.             $this->numStatements++;
  20.            
  21.             $args = func_get_args();
  22.             $PDOS = call_user_func_array(array(&$this->PDO, 'prepare'), $args);
  23.            
  24.             return new PDOpStatement($this, $PDOS);
  25.         }
  26.         public function query() {
  27.             $this->numExecutes++;
  28.             $this->numStatements++;
  29.            
  30.             $args = func_get_args();
  31.             $PDOS = call_user_func_array(array(&$this->PDO, 'query'), $args);
  32.            
  33.             return new PDOpStatement($this, $PDOS);
  34.         }
  35.         public function exec() {
  36.             $this->numExecutes++;
  37.            
  38.             $args = func_get_args();
  39.             return call_user_func_array(array(&$this->PDO, 'exec'), $args);
  40.         }
  41.     }
  42.     class PDOpStatement implements IteratorAggregate {
  43.         protected $PDOS;
  44.         protected $PDOp;
  45.         public function __construct($PDOp, $PDOS) {
  46.             $this->PDOp = $PDOp;
  47.             $this->PDOS = $PDOS;
  48.         }
  49.         public function __call($func, $args) {
  50.             return call_user_func_array(array(&$this->PDOS, $func), $args);
  51.         }
  52.         public function bindColumn($column, &$param, $type=NULL) {
  53.             if ($type === NULL)
  54.                 $this->PDOS->bindColumn($column, $param);
  55.             else
  56.                 $this->PDOS->bindColumn($column, $param, $type);
  57.         }
  58.         public function bindParam($column, &$param, $type=NULL) {
  59.             if ($type === NULL)
  60.                 $this->PDOS->bindParam($column, $param);
  61.             else
  62.                 $this->PDOS->bindParam($column, $param, $type);
  63.         }
  64.         public function execute() {
  65.             $this->PDOp->numExecutes++;
  66.             $args = func_get_args();
  67.             return call_user_func_array(array(&$this->PDOS, 'execute'), $args);
  68.         }
  69.         public function __get($property) {
  70.             return $this->PDOS->$property;
  71.         }
  72.         public function getIterator() {
  73.             return $this->PDOS;
  74.         }
  75.    }
  76. ?>
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