From d1c0dd763a113acfeb29ac136fa868e76c91d7dc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Jul 2007 18:53:27 +0000 Subject: [PATCH] Adding PDO tests --- php520-test/PDO.php | 93 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 php520-test/PDO.php diff --git a/php520-test/PDO.php b/php520-test/PDO.php new file mode 100644 index 0000000..1e9d1c1 --- /dev/null +++ b/php520-test/PDO.php @@ -0,0 +1,93 @@ +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 -- 2.22.5