![]() PHP: PDO - Manual. I wanted to extend PDO class to store statistics of DB usage, and I faced some problems. I wanted to count number of created statements and number of their executings. So PDOStatement should have link to PDO that created it and stores the statistical info. The problem was that I didn't knew how PDO creates PDOStatement (constructor parameters and so on), so I have created these two classes: < ?
PDOp {protected $PDO; public $num. Executes; public $num. Statements; public function __construct($dsn, $user=NULL, $pass=NULL, $driver_options=NULL) {$this- > PDO = new PDO($dsn, $user, $pass, $driver_options); $this- > num. Executes = 0; $this- > num. Statements = 0; }public function __call($func, $args) {return call_user_func_array(array(& $this- > PDO, $func), $args); }public function prepare() {$this- > num. Statements++; $args = func_get_args(); $PDOS = call_user_func_array(array(& $this- > PDO, 'prepare'), $args); return new PDOp. Statement($this, $PDOS); }public function query() {$this- > num. Executes++; $this- > num. Statements++; $args = func_get_args(); $PDOS = call_user_func_array(array(& $this- > PDO, 'query'), $args); return new PDOp. Statement($this, $PDOS); }public function exec() {$this- > num. Executes++; $args = func_get_args(); return call_user_func_array(array(& $this- > PDO, 'exec'), $args); }}class PDOp. ![]() Statement implements Iterator. Aggregate {protected $PDOS; protected $PDOp; public function __construct($PDOp, $PDOS) {$this- > PDOp = $PDOp; $this- > PDOS = $PDOS; }public function __call($func, $args) {return call_user_func_array(array(& $this- > PDOS, $func), $args); }public function bind. Column($column, & $param, $type=NULL) {if ($type === NULL)$this- > PDOS- > bind. Column($column, $param); else$this- > PDOS- > bind. Column($column, $param, $type); }public function bind. Param($column, & $param, $type=NULL) {if ($type === NULL)$this- > PDOS- > bind. How do I set up an ODBC Data Source Name for Stata in Windows?Param($column, $param); else$this- > PDOS- > bind. Param($column, $param, $type); }public function execute() {$this- > PDOp- > num. Executes++; $args = func_get_args(); return call_user_func_array(array(& $this- > PDOS, 'execute'), $args); }public function __get($property) {return $this- > PDOS- > $property; }public function get. Performance comparison of a wide spectrum of web application frameworks and platforms using community-contributed test implementations. Iterator() {return $this- > PDOS; }}?> Classes have properties with original PDO and PDOStatement objects, which are providing the functionality to PDOp and PDOp. Statement. From outside, PDOp and PDOp. Statement look like PDO and PDOStatement, but also are providing wanted info. SQL Server Central. Microsoft SQL Server tutorials, training & forum. Whether you’re only just starting to explore the advantages of Dev. Ops or you’re already fully immersed in the journey, including the database brings additional advantages. Take a few minutes to complete our Database Dev. Ops Maturity Assessment and you’ll better understand how advanced your current processes are, receive recommendations for improvements, and see how your maturity level compares with that of your peers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |