diff options
-rwxr-xr-x | ext/pdo/tests/pdo_026.inc | 75 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_026.phpt | 51 | ||||
-rwxr-xr-x | ext/pdo_pgsql/tests/pdo_026.phpt | 51 | ||||
-rwxr-xr-x | ext/pdo_sqlite/tests/pdo_026.phpt | 51 | ||||
-rwxr-xr-x | ext/sqlite/tests/pdo/pdo_026.phpt | 51 |
5 files changed, 279 insertions, 0 deletions
diff --git a/ext/pdo/tests/pdo_026.inc b/ext/pdo/tests/pdo_026.inc new file mode 100755 index 0000000000..c5f2ce565b --- /dev/null +++ b/ext/pdo/tests/pdo_026.inc @@ -0,0 +1,75 @@ +<?php # vim:ft=php + +require_once('pdo.inc'); + +set_sql('create1', 'CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); +set_sql('insert1', "INSERT INTO test VALUES(?, ?, ?)"); +set_sql('select', 'SELECT * FROM test'); + +$data = array( + array('10', 'Abc', 'zxy'), + array('20', 'Def', 'wvu'), + array('30', 'Ghi', 'tsr'), +); + +class PDOStatementX extends PDOStatement +{ + public $dbh; + + protected function __construct($dbh) + { + $this->dbh = $dbh; + echo __METHOD__ . "()\n"; + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } +} + +class PDODatabase extends PDO +{ + function __construct($connect) + { + echo __METHOD__ . "()\n"; + parent::__construct($connect); + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } + + function query($sql) + { + echo __METHOD__ . "()\n"; + $stmt = $this->prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); + $stmt->setFetchMode(PDO_FETCH_ASSOC); + $stmt->execute(); + return $stmt; + } +} + +$DB = new PDODatabase($CONNECTION); +var_dump(get_class($DB)); + +$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING); + +$DB->exec($SQL['create1']); + +$stmt = $DB->prepare($SQL['insert1']); +var_dump(get_class($stmt)); +foreach ($data as $row) { + $stmt->execute($row); +} + +$stmt = $DB->query($SQL['select']); +var_dump(get_class($stmt)); +var_dump(get_class($stmt->dbh)); + +foreach($stmt as $obj) { + var_dump($obj); +} + +?> diff --git a/ext/pdo_mysql/tests/pdo_026.phpt b/ext/pdo_mysql/tests/pdo_026.phpt new file mode 100755 index 0000000000..e55b4578f9 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_026.phpt @@ -0,0 +1,51 @@ +--TEST-- +PDO_MySQL: Deriving PDO +--SKIPIF-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_026.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +PDODatabase::__construct() +string(11) "PDODatabase" +string(12) "PDOStatement" +PDODatabase::query() +PDOStatementX::__construct() +string(13) "PDOStatementX" +string(11) "PDODatabase" +array(3) { + ["id"]=> + string(2) "10" + ["val"]=> + string(3) "Abc" + ["val2"]=> + string(3) "zxy" +} +array(3) { + ["id"]=> + string(2) "20" + ["val"]=> + string(3) "Def" + ["val2"]=> + string(3) "wvu" +} +array(3) { + ["id"]=> + string(2) "30" + ["val"]=> + string(3) "Ghi" + ["val2"]=> + string(3) "tsr" +} +===DONE=== +PDODatabase::__destruct() +PDOStatementX::__destruct() diff --git a/ext/pdo_pgsql/tests/pdo_026.phpt b/ext/pdo_pgsql/tests/pdo_026.phpt new file mode 100755 index 0000000000..68aa14cf7d --- /dev/null +++ b/ext/pdo_pgsql/tests/pdo_026.phpt @@ -0,0 +1,51 @@ +--TEST-- +PDO_PGSQL: Deriving PDO +--SKIPIF-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_026.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +PDODatabase::__construct() +string(11) "PDODatabase" +string(12) "PDOStatement" +PDODatabase::query() +PDOStatementX::__construct() +string(13) "PDOStatementX" +string(11) "PDODatabase" +array(3) { + ["id"]=> + int(10) + ["val"]=> + string(3) "Abc" + ["val2"]=> + string(3) "zxy" +} +array(3) { + ["id"]=> + int(20) + ["val"]=> + string(3) "Def" + ["val2"]=> + string(3) "wvu" +} +array(3) { + ["id"]=> + int(30) + ["val"]=> + string(3) "Ghi" + ["val2"]=> + string(3) "tsr" +} +===DONE=== +PDODatabase::__destruct() +PDOStatementX::__destruct() diff --git a/ext/pdo_sqlite/tests/pdo_026.phpt b/ext/pdo_sqlite/tests/pdo_026.phpt new file mode 100755 index 0000000000..066648f453 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_026.phpt @@ -0,0 +1,51 @@ +--TEST-- +PDO_SQLite: Deriving PDO +--SKIPIF-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_026.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +PDODatabase::__construct() +string(11) "PDODatabase" +string(12) "PDOStatement" +PDODatabase::query() +PDOStatementX::__construct() +string(13) "PDOStatementX" +string(11) "PDODatabase" +array(3) { + ["id"]=> + string(2) "10" + ["val"]=> + string(3) "Abc" + ["val2"]=> + string(3) "zxy" +} +array(3) { + ["id"]=> + string(2) "20" + ["val"]=> + string(3) "Def" + ["val2"]=> + string(3) "wvu" +} +array(3) { + ["id"]=> + string(2) "30" + ["val"]=> + string(3) "Ghi" + ["val2"]=> + string(3) "tsr" +} +===DONE=== +PDODatabase::__destruct() +PDOStatementX::__destruct() diff --git a/ext/sqlite/tests/pdo/pdo_026.phpt b/ext/sqlite/tests/pdo/pdo_026.phpt new file mode 100755 index 0000000000..d9bc504c57 --- /dev/null +++ b/ext/sqlite/tests/pdo/pdo_026.phpt @@ -0,0 +1,51 @@ +--TEST-- +PDO_SQLite2: Deriving PDO +--SKIPIF-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_026.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +PDODatabase::__construct() +string(11) "PDODatabase" +string(12) "PDOStatement" +PDODatabase::query() +PDOStatementX::__construct() +string(13) "PDOStatementX" +string(11) "PDODatabase" +array(3) { + ["id"]=> + string(2) "10" + ["val"]=> + string(3) "Abc" + ["val2"]=> + string(3) "zxy" +} +array(3) { + ["id"]=> + string(2) "20" + ["val"]=> + string(3) "Def" + ["val2"]=> + string(3) "wvu" +} +array(3) { + ["id"]=> + string(2) "30" + ["val"]=> + string(3) "Ghi" + ["val2"]=> + string(3) "tsr" +} +===DONE=== +PDODatabase::__destruct() +PDOStatementX::__destruct() |