]>
src.bluestatic.org Git - isso.git/blob - php520-test/PDO.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 class MyPDO
extends PDO
24 public $history = array();
26 public function __construct()
28 $args = func_get_args();
29 call_user_func_array(array($this, 'parent::__construct'), $args);
30 $this->setAttribute(PDO
::ATTR_STATEMENT_CLASS
, array('MyStatement', array($this)));
33 public function exec()
35 $args = func_get_args();
37 call_user_func_array(array($this, 'parent::exec'), $args);
38 $this->history
[] = func_get_args();
41 public function query()
44 $args = func_get_args();
45 call_user_func_array(array($this, 'parent::query'), $args);
46 $this->history
[] = $args;
50 class MyStatement
extends PDOStatement
54 private function __construct($pdo)
59 public function execute()
61 $args = func_get_args();
62 call_user_func_array(array($this, 'parent::execute'), $args);
63 $this->pdo
->history
[] = $this->queryString
;
66 public function query()
68 $args = func_get_args();
69 call_user_func_array(array($this, 'parent::query'), $args);
70 $this->pdo
->history
[] = $this->queryString
;
74 $db = new MyPDO('mysql:host=localhost;dbname=test', 'mysql', 'elssur');
76 $smt = $db->prepare("SELECT * FROM user WHERE userid = :hi");
77 $smt->bindValue('hi', null);
79 // $smt->execute(array(1));
83 print_r($smt->fetch());
85 print_r($db->history
);