]> src.bluestatic.org Git - isso.git/blob - php520-test/PDO.php
Changing the registry part of BSRegister to be a new inner class called BSVariableReg...
[isso.git] / php520-test / PDO.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ISSO
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
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 [#]gpl[#] of the License.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 class MyPDO extends PDO
23 {
24 public $history = array();
25
26 public function __construct()
27 {
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)));
31 }
32
33 public function exec()
34 {
35 $args = func_get_args();
36 echo 'hi';
37 call_user_func_array(array($this, 'parent::exec'), $args);
38 $this->history[] = func_get_args();
39 }
40
41 public function query()
42 {
43 echo 'moo';
44 $args = func_get_args();
45 call_user_func_array(array($this, 'parent::query'), $args);
46 $this->history[] = $args;
47 }
48 }
49
50 class MyStatement extends PDOStatement
51 {
52 private $pdo;
53
54 private function __construct($pdo)
55 {
56 $this->pdo = $pdo;
57 }
58
59 public function execute()
60 {
61 $args = func_get_args();
62 call_user_func_array(array($this, 'parent::execute'), $args);
63 $this->pdo->history[] = $this->queryString;
64 }
65
66 public function query()
67 {
68 $args = func_get_args();
69 call_user_func_array(array($this, 'parent::query'), $args);
70 $this->pdo->history[] = $this->queryString;
71 }
72 }
73
74 $db = new MyPDO('mysql:host=localhost;dbname=test', 'mysql', 'elssur');
75
76 $smt = $db->prepare("SELECT * FROM user WHERE userid = :hi");
77 $smt->bindValue('hi', null);
78 // echo $smt;
79 // $smt->execute(array(1));
80
81 $smt->execute();
82
83 print_r($smt->fetch());
84
85 print_r($db->history);
86
87 /*=====================================================================*\
88 || ###################################################################
89 || # $HeadURL$
90 || # $Id$
91 || ###################################################################
92 \*=====================================================================*/
93 ?>