Adding PDO tests
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jul 2007 18:53:27 +0000 (18:53 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jul 2007 18:53:27 +0000 (18:53 +0000)
php520-test/PDO.php [new file with mode: 0644]

diff --git a/php520-test/PDO.php b/php520-test/PDO.php
new file mode 100644 (file)
index 0000000..1e9d1c1
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/*=====================================================================*\
+|| ###################################################################
+|| # ISSO
+|| # Copyright ©2002-[#]year[#] Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+class MyPDO extends PDO
+{
+       public $history = array();
+       
+       public function __construct()
+       {
+               $args = func_get_args();
+               call_user_func_array(array($this, 'parent::__construct'), $args);
+               $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyStatement', array($this)));
+       }
+       
+       public function exec()
+       {
+               $args = func_get_args();
+               echo 'hi';
+               call_user_func_array(array($this, 'parent::exec'), $args);
+               $this->history[] = func_get_args();
+       }
+       
+       public function query()
+       {
+               echo 'moo';
+               $args = func_get_args();
+               call_user_func_array(array($this, 'parent::query'), $args);
+               $this->history[] = $args;
+       }
+}
+
+class MyStatement extends PDOStatement
+{
+       private $pdo;
+       
+       private function __construct($pdo)
+       {
+               $this->pdo = $pdo;
+       }
+       
+       public function execute()
+       {
+               $args = func_get_args();
+               call_user_func_array(array($this, 'parent::execute'), $args);
+               $this->pdo->history[] = $this->queryString;
+       }
+       
+       public function query()
+       {
+               $args = func_get_args();
+               call_user_func_array(array($this, 'parent::query'), $args);
+               $this->pdo->history[] = $this->queryString;
+       }
+}
+
+$db = new MyPDO('mysql:host=localhost;dbname=test', 'mysql', 'elssur');
+
+$smt = $db->prepare("SELECT * FROM user WHERE userid = :hi");
+$smt->bindValue('hi', null);
+// echo $smt;
+// $smt->execute(array(1));
+
+$smt->execute();
+
+print_r($smt->fetch());
+
+print_r($db->history);
+
+/*=====================================================================*\
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file