diff --git a/hphp/test/zend/bad/ext-pdo/bug61292.php b/hphp/test/zend/bad/ext-pdo/bug61292.php new file mode 100644 index 000000000..52911eaed --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug61292.php @@ -0,0 +1,22 @@ + TRUE); + parent::__construct(getenv("PDOTEST_DSN"), getenv("PDOTEST_USER"), getenv("PDOTEST_PASS"), $options); + } + + var $bar = array(); + + public function foo() + { + var_dump($this->bar); + } +} + +(new Database_SQL)->foo(); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug61292.php.expectf b/hphp/test/zend/bad/ext-pdo/bug61292.php.expectf new file mode 100644 index 000000000..82beeb215 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug61292.php.expectf @@ -0,0 +1,2 @@ +array(0) { +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_34630.php b/hphp/test/zend/bad/ext-pdo/bug_34630.php new file mode 100644 index 000000000..d3e6b9458 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_34630.php @@ -0,0 +1,36 @@ +getAttribute(PDO::ATTR_DRIVER_NAME); +$is_oci = $driver == 'oci'; + +if ($is_oci) { + $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val BLOB)'); +} else { + $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(256))'); +} +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$fp = tmpfile(); +fwrite($fp, "I am the LOB data"); +rewind($fp); + +if ($is_oci) { + /* oracle is a bit different; you need to initiate a transaction otherwise + * the empty blob will be committed implicitly when the statement is + * executed */ + $db->beginTransaction(); + $insert = $db->prepare("insert into test (id, val) values (1, EMPTY_BLOB()) RETURNING val INTO :blob"); +} else { + $insert = $db->prepare("insert into test (id, val) values (1, :blob)"); +} +$insert->bindValue(':blob', $fp, PDO::PARAM_LOB); +$insert->execute(); +$insert = null; + +$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); +var_dump($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_34630.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_34630.php.expectf new file mode 100644 index 000000000..806b1e7df --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_34630.php.expectf @@ -0,0 +1,9 @@ +array(1) { + [0]=> + array(2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(17) "I am the LOB data" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_34687.php b/hphp/test/zend/bad/ext-pdo/bug_34687.php new file mode 100644 index 000000000..7e6c0c911 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_34687.php @@ -0,0 +1,18 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); +$x = $db->query("UPDATE non_existent_pdo_test_table set foo = 'bar'"); + +var_dump($x); +$code = $db->errorCode(); +if ($code !== '00000' && strlen($code)) { + echo "OK: $code\n"; +} else { + echo "ERR: $code\n"; + print_r($db->errorInfo()); +} + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_34687.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_34687.php.expectf new file mode 100644 index 000000000..e6d84b3a9 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_34687.php.expectf @@ -0,0 +1,2 @@ +bool(false) +OK: %s \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_35671.php b/hphp/test/zend/bad/ext-pdo/bug_35671.php new file mode 100644 index 000000000..ae2e754f4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_35671.php @@ -0,0 +1,22 @@ +exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32))'); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$insert = $db->prepare("insert into test (field1, field2, field3) values (:value1, :value2, :value3)"); + +$parm = array( + ":value1" => 15, + ":value2" => 20, + ":value3" => 25 +); + +$insert->execute($parm); +$insert = null; + +var_dump($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_35671.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_35671.php.expectf new file mode 100644 index 000000000..7bb47ddce --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_35671.php.expectf @@ -0,0 +1,11 @@ +array(1) { + [0]=> + array(3) { + ["field1"]=> + string(2) "15" + ["field2"]=> + string(2) "20" + ["field3"]=> + string(2) "25" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_36428.php b/hphp/test/zend/bad/ext-pdo/bug_36428.php new file mode 100644 index 000000000..6e2e0dd13 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_36428.php @@ -0,0 +1,12 @@ +exec("CREATE TABLE test (a VARCHAR(10))"); +$db->exec("INSERT INTO test (a) VALUES ('xyz')"); +$res = $db->query("SELECT a FROM test"); +var_dump($res->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, 'SimpleXMLElement', array(''))); + +?> +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_36428.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_36428.php.expectf new file mode 100644 index 000000000..d0580fb24 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_36428.php.expectf @@ -0,0 +1,8 @@ +array(1) { + [0]=> + object(SimpleXMLElement)#%d (1) { + ["a"]=> + string(3) "xyz" + } +} +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_36798.php b/hphp/test/zend/bad/ext-pdo/bug_36798.php new file mode 100644 index 000000000..7ad0fa6b1 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_36798.php @@ -0,0 +1,17 @@ +exec("SET NAMES 'LATIN1'"); // needed for PostgreSQL +$db->exec("CREATE TABLE test (id INTEGER)"); +$db->exec("INSERT INTO test (id) VALUES (1)"); + +$stmt = $db->prepare("SELECT 'Ã' as test FROM test WHERE id = :id"); +$stmt->execute(array(":id" => 1)); + +$row = $stmt->fetch(PDO::FETCH_NUM); +var_dump( $row ); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_36798.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_36798.php.expectf new file mode 100644 index 000000000..2d952d137 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_36798.php.expectf @@ -0,0 +1,4 @@ +array(1) { + [0]=> + string(1) "Ã" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_38253.php b/hphp/test/zend/bad/ext-pdo/bug_38253.php new file mode 100644 index 000000000..53952ab07 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_38253.php @@ -0,0 +1,30 @@ +exec ("create table test (id integer primary key, n varchar(255))"); +$pdo->exec ("INSERT INTO test (id, n) VALUES (1, 'hi')"); + +$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS); +$stmt = $pdo->prepare ("SELECT * FROM test"); +$stmt->execute(); +var_dump($stmt->fetchAll()); + +$pdo = PDOTest::factory(); + +if ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') { + $type = "clob"; +} else{ + $type = "text"; +} + +$pdo->exec ("create table test2 (id integer primary key, n $type)"); +$pdo->exec ("INSERT INTO test2 (id, n) VALUES (1,'hi')"); + +$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC); +$stmt = $pdo->prepare ("SELECT * FROM test2"); +$stmt->execute(); +var_dump($stmt->fetchAll()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_38253.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_38253.php.expectf new file mode 100644 index 000000000..1291f67a5 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_38253.php.expectf @@ -0,0 +1,8 @@ +HipHop Warning: %a +HipHop Warning: %a +array(0) { +} +HipHop Warning: %a +HipHop Warning: %a +array(0) { +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_38394.php b/hphp/test/zend/bad/ext-pdo/bug_38394.php new file mode 100644 index 000000000..64a9b820f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_38394.php @@ -0,0 +1,17 @@ +exec("CREATE TABLE test (a INT, b INT, c INT)"); +$s = $db->prepare("INSERT INTO test (a,b,c) VALUES (:a,:b,:c)"); + +$s->execute(array('a' => 1, 'b' => 2, 'c' => 3)); + +@$s->execute(array('a' => 5, 'b' => 6, 'c' => 7, 'd' => 8)); + +$s->execute(array('a' => 9, 'b' => 10, 'c' => 11)); + +var_dump($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_ASSOC)); +?> +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_38394.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_38394.php.expectf new file mode 100644 index 000000000..b758d1bfe --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_38394.php.expectf @@ -0,0 +1,21 @@ +array(2) { + [0]=> + array(3) { + ["a"]=> + string(1) "1" + ["b"]=> + string(1) "2" + ["c"]=> + string(1) "3" + } + [1]=> + array(3) { + ["a"]=> + string(1) "9" + ["b"]=> + string(2) "10" + ["c"]=> + string(2) "11" + } +} +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_39398.php b/hphp/test/zend/bad/ext-pdo/bug_39398.php new file mode 100644 index 000000000..877967d9b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_39398.php @@ -0,0 +1,15 @@ +exec("CREATE TABLE test (test INT)"); + +$boolean = 1; +$stmt = $db->prepare('INSERT INTO test VALUES (:boolean)'); +$stmt->bindValue(':boolean', isset($boolean), PDO::PARAM_INT); +$stmt->execute(); + +var_dump($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_ASSOC)); +?> +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_39398.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_39398.php.expectf new file mode 100644 index 000000000..59aa06fe1 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_39398.php.expectf @@ -0,0 +1,8 @@ +array(1) { + [0]=> + array(1) { + ["test"]=> + string(1) "1" + } +} +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_39656.php b/hphp/test/zend/bad/ext-pdo/bug_39656.php new file mode 100644 index 000000000..88fd31ed2 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_39656.php @@ -0,0 +1,26 @@ +exec("DROP TABLE test"); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$db->exec("CREATE TABLE test (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)"); +$db->exec("INSERT INTO test (id, usr) VALUES (1, 'user')"); + +$stmt = $db->prepare("SELECT * FROM test WHERE id = ?"); +$stmt->bindValue(1, 1, PDO::PARAM_INT ); +$stmt->execute(); +$row = $stmt->fetch(); +var_dump( $row ); + +$stmt->execute(); +$stmt->closeCursor(); +$row = $stmt->fetch(); // this line will crash CLI +var_dump( $row ); + +@$db->exec("DROP TABLE test"); +echo "Done\n"; +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_39656.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_39656.php.expectf new file mode 100644 index 000000000..d9c0dcd81 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_39656.php.expectf @@ -0,0 +1,12 @@ +array(4) { + ["id"]=> + string(1) "1" + [0]=> + string(1) "1" + ["usr"]=> + string(4) "user" + [1]=> + string(4) "user" +} +bool(false) +Done \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_40285.php b/hphp/test/zend/bad/ext-pdo/bug_40285.php new file mode 100644 index 000000000..ff9bc1bd5 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_40285.php @@ -0,0 +1,14 @@ +exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32), field4 INT)'); + +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); +$s = $db->prepare("INSERT INTO test VALUES( ':id', 'name', 'section', 22)" ); +$s->execute(); + +echo "Done\n"; +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_40285.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_40285.php.expectf new file mode 100644 index 000000000..8ad96f878 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_40285.php.expectf @@ -0,0 +1 @@ +Done \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_42917.php b/hphp/test/zend/bad/ext-pdo/bug_42917.php new file mode 100644 index 000000000..e05f76a2f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_42917.php @@ -0,0 +1,16 @@ +exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))"); + +for ($i = 0; $i < 5; $i++) { + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); +} + +$res = $db->query("SELECT a,b FROM test"); +$res->setFetchMode(PDO::FETCH_KEY_PAIR); +var_dump($res->fetchAll()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_42917.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_42917.php.expectf new file mode 100644 index 000000000..f0e0869a8 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_42917.php.expectf @@ -0,0 +1,12 @@ +array(5) { + ["test0"]=> + string(1) "0" + ["test1"]=> + string(1) "1" + ["test2"]=> + string(1) "2" + ["test3"]=> + string(1) "3" + ["test4"]=> + string(1) "4" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43130.php b/hphp/test/zend/bad/ext-pdo/bug_43130.php new file mode 100644 index 000000000..d88a60e44 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43130.php @@ -0,0 +1,20 @@ +getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + +$db->exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))"); + +for ($i = 0; $i < 5; $i++) { + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); +} + +$stmt = $db->prepare("SELECT a FROM test WHERE b=:id-value"); +$stmt->bindParam(':id-value', $id); +$id = '1'; +$stmt->execute(); +var_dump($stmt->fetch(PDO::FETCH_COLUMN)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43130.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_43130.php.expectf new file mode 100644 index 000000000..fee494fa0 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43130.php.expectf @@ -0,0 +1,3 @@ +HipHop Warning: %a +HipHop Warning: %a +bool(false) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43139.php b/hphp/test/zend/bad/ext-pdo/bug_43139.php new file mode 100644 index 000000000..07f1630b1 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43139.php @@ -0,0 +1,17 @@ +setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + +$from = ''; +if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') { + $from = 'from dual'; +} else if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'firebird') { + $from = 'FROM RDB$DATABASE'; +} + +var_dump($db->query("select 0 as abc, 1 as xyz, 2 as def $from")->fetchAll(PDO::FETCH_GROUP)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43139.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_43139.php.expectf new file mode 100644 index 000000000..3fc04ea76 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43139.php.expectf @@ -0,0 +1,12 @@ +array(1) { + [0]=> + array(1) { + [0]=> + array(2) { + ["xyz"]=> + string(1) "1" + ["def"]=> + string(1) "2" + } + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43663.php b/hphp/test/zend/bad/ext-pdo/bug_43663.php new file mode 100644 index 000000000..df236a966 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43663.php @@ -0,0 +1,16 @@ +foo(); +$a->bar(); \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_43663.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_43663.php.expectf new file mode 100644 index 000000000..458c79d66 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_43663.php.expectf @@ -0,0 +1,2 @@ +Called foo in test +Called bar in test \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44173.php b/hphp/test/zend/bad/ext-pdo/bug_44173.php new file mode 100644 index 000000000..4ee107387 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44173.php @@ -0,0 +1,45 @@ +exec("CREATE TABLE test (x int)"); +$db->exec("INSERT INTO test VALUES (1)"); + + +// Bug entry [1] +$stmt = $db->query(); +var_dump($stmt); + + +// Bug entry [2] -- 1 is PDO::FETCH_LAZY +$stmt = $db->query("SELECT * FROM test", PDO::FETCH_LAZY, 0, 0); +var_dump($stmt); + + +// Bug entry [3] +$stmt = $db->query("SELECT * FROM test", 'abc'); +var_dump($stmt); + + +// Bug entry [4] +$stmt = $db->query("SELECT * FROM test", PDO::FETCH_CLASS, 0, 0, 0); +var_dump($stmt); + + +// Bug entry [5] +$stmt = $db->query("SELECT * FROM test", PDO::FETCH_INTO); +var_dump($stmt); + + +// Bug entry [6] +$stmt = $db->query("SELECT * FROM test", PDO::FETCH_COLUMN); +var_dump($stmt); + + +// Bug entry [7] +$stmt = $db->query("SELECT * FROM test", PDO::FETCH_CLASS); +var_dump($stmt); + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44173.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_44173.php.expectf new file mode 100644 index 000000000..cb1612d2f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44173.php.expectf @@ -0,0 +1,14 @@ +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44409.php b/hphp/test/zend/bad/ext-pdo/bug_44409.php new file mode 100644 index 000000000..2cfb2bab9 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44409.php @@ -0,0 +1,31 @@ +exec("CREATE TABLE test (dat varchar(100))"); +$db->exec("INSERT INTO test (dat) VALUES ('Data from DB')"); + +class bug44409 implements Serializable +{ + public function __construct() + { + printf("Method called: %s()\n", __METHOD__); + } + + public function serialize() + { + return "any data from serizalize()"; + } + + public function unserialize($dat) + { + printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true)); + } +} + +$stmt = $db->query("SELECT * FROM test"); + +print_r($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, "bug44409")); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44409.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_44409.php.expectf new file mode 100644 index 000000000..a4c914491 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44409.php.expectf @@ -0,0 +1,8 @@ +Method called: bug44409::unserialize('Data from DB') +Array +( + [0] => bug44409 Object + ( + ) + +) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44861.php b/hphp/test/zend/bad/ext-pdo/bug_44861.php new file mode 100644 index 000000000..862dc11a4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44861.php @@ -0,0 +1,46 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') { + $from = 'FROM DUAL'; + $ob = '1'; +} else { + $from = ''; + $ob = 'r'; +} + +$query = "SELECT 'row1' AS r $from UNION SELECT 'row2' $from UNION SELECT 'row3' $from UNION SELECT 'row4' $from ORDER BY $ob"; +$aParams = array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL); + +$res = $db->prepare($query, $aParams); +$res->execute(); +var_dump($res->fetchColumn()); +var_dump($res->fetchColumn()); +var_dump($res->fetchColumn()); +var_dump($res->fetchColumn()); +var_dump($res->fetchColumn()); + +var_dump($res->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_ABS, 3)); +var_dump($res->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_PRIOR)); +var_dump($res->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_FIRST)); +var_dump($res->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_LAST)); +var_dump($res->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_REL, -1)); + +var_dump($res->fetchAll(PDO::FETCH_ASSOC)); + +// Test binding params via emulated prepared query +$res = $db->prepare("SELECT ? $from", $aParams); +$res->execute(array("it's working")); +var_dump($res->fetch(PDO::FETCH_NUM)); + + +// Test bug #48188, trying to execute again +$res->execute(array("try again")); +var_dump($res->fetchColumn()); +var_dump($res->fetchColumn()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_44861.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_44861.php.expectf new file mode 100644 index 000000000..3f72014df --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_44861.php.expectf @@ -0,0 +1,38 @@ +string(4) "row1" +string(4) "row2" +string(4) "row3" +string(4) "row4" +bool(false) +array(1) { + [0]=> + string(4) "row3" +} +array(1) { + [0]=> + string(4) "row2" +} +array(1) { + [0]=> + string(4) "row1" +} +array(1) { + [0]=> + string(4) "row4" +} +array(1) { + [0]=> + string(4) "row3" +} +array(1) { + [0]=> + array(1) { + ["r"]=> + string(4) "row4" + } +} +array(1) { + [0]=> + string(12) "it's working" +} +string(9) "try again" +bool(false) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_50458.php b/hphp/test/zend/bad/ext-pdo/bug_50458.php new file mode 100644 index 000000000..e83b89003 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_50458.php @@ -0,0 +1,12 @@ +exec("CREATE TABLE test (a VARCHAR(10))"); +$db->exec("INSERT INTO test (a) VALUES ('xyz')"); +$res = $db->query("SELECT a FROM test"); +var_dump($res->fetchAll(PDO::FETCH_FUNC, function($a) { return strtoupper($a); })); + +?> +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/bug_50458.php.expectf b/hphp/test/zend/bad/ext-pdo/bug_50458.php.expectf new file mode 100644 index 000000000..a2cec9f99 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/bug_50458.php.expectf @@ -0,0 +1,5 @@ +array(1) { + [0]=> + string(3) "XYZ" +} +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_001.php b/hphp/test/zend/bad/ext-pdo/pdo_001.php new file mode 100644 index 000000000..32451f2b8 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_001.php @@ -0,0 +1,15 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_001.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_001.php.expectf new file mode 100644 index 000000000..3e953e56d --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_001.php.expectf @@ -0,0 +1,23 @@ +array(3) { + [0]=> + array(2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + array(2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + array(2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_002.php b/hphp/test/zend/bad/ext-pdo/pdo_002.php new file mode 100644 index 000000000..1cd43e04a --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_002.php @@ -0,0 +1,15 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +var_dump($stmt->fetchAll(PDO::FETCH_NUM)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_002.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_002.php.expectf new file mode 100644 index 000000000..5ef11d8fe --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_002.php.expectf @@ -0,0 +1,23 @@ +array(3) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "A" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(1) "B" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_003.php b/hphp/test/zend/bad/ext-pdo/pdo_003.php new file mode 100644 index 000000000..988092841 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_003.php @@ -0,0 +1,15 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_003.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_003.php.expectf new file mode 100644 index 000000000..cb808bf22 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_003.php.expectf @@ -0,0 +1,35 @@ +array(3) { + [0]=> + array(4) { + ["id"]=> + string(1) "1" + [0]=> + string(1) "1" + ["val"]=> + string(1) "A" + [1]=> + string(1) "A" + } + [1]=> + array(4) { + ["id"]=> + string(1) "2" + [0]=> + string(1) "2" + ["val"]=> + string(1) "B" + [1]=> + string(1) "B" + } + [2]=> + array(4) { + ["id"]=> + string(1) "3" + [0]=> + string(1) "3" + ["val"]=> + string(1) "C" + [1]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_004.php b/hphp/test/zend/bad/ext-pdo/pdo_004.php new file mode 100644 index 000000000..4da477c7b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_004.php @@ -0,0 +1,15 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +var_dump($stmt->fetchAll(PDO::FETCH_OBJ)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_004.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_004.php.expectf new file mode 100644 index 000000000..469f43fc7 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_004.php.expectf @@ -0,0 +1,23 @@ +array(3) { + [0]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_005.php b/hphp/test/zend/bad/ext-pdo/pdo_005.php new file mode 100644 index 000000000..77b10a1a8 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_005.php @@ -0,0 +1,40 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A', 'AA')"); +$db->exec("INSERT INTO test VALUES(2, 'B', 'BB')"); +$db->exec("INSERT INTO test VALUES(3, 'C', 'CC')"); + +$stmt = $db->prepare('SELECT id, val, val2 from test'); + +class TestBase +{ + public $id; + protected $val; + private $val2; +} + +class TestDerived extends TestBase +{ + protected $row; + + public function __construct(&$row) + { + echo __METHOD__ . "($row,{$this->id})\n"; + $this->row = $row++; + } +} + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS)); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestBase')); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestDerived', array(0))); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_005.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_005.php.expectf new file mode 100644 index 000000000..38bc01c0b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_005.php.expectf @@ -0,0 +1,102 @@ +array(3) { + [0]=> + object(stdClass)#%d (3) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + ["val2"]=> + string(2) "AA" + } + [1]=> + object(stdClass)#%d (3) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + ["val2"]=> + string(2) "BB" + } + [2]=> + object(stdClass)#%d (3) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + ["val2"]=> + string(2) "CC" + } +} +array(3) { + [0]=> + object(TestBase)#%d (3) { + ["id"]=> + string(1) "1" + ["val":protected]=> + string(1) "A" + ["val2":"TestBase":private]=> + string(2) "AA" + } + [1]=> + object(TestBase)#%d (3) { + ["id"]=> + string(1) "2" + ["val":protected]=> + string(1) "B" + ["val2":"TestBase":private]=> + string(2) "BB" + } + [2]=> + object(TestBase)#%d (3) { + ["id"]=> + string(1) "3" + ["val":protected]=> + string(1) "C" + ["val2":"TestBase":private]=> + string(2) "CC" + } +} +TestDerived::__construct(0,1) +TestDerived::__construct(1,2) +TestDerived::__construct(2,3) +array(3) { + [0]=> + object(TestDerived)#%d (5) { + ["row":protected]=> + int(0) + ["id"]=> + string(1) "1" + ["val":protected]=> + string(1) "A" + ["val2":"TestBase":private]=> + NULL + ["val2"]=> + string(2) "AA" + } + [1]=> + object(TestDerived)#%d (5) { + ["row":protected]=> + int(1) + ["id"]=> + string(1) "2" + ["val":protected]=> + string(1) "B" + ["val2":"TestBase":private]=> + NULL + ["val2"]=> + string(2) "BB" + } + [2]=> + object(TestDerived)#%d (5) { + ["row":protected]=> + int(2) + ["id"]=> + string(1) "3" + ["val":protected]=> + string(1) "C" + ["val2":"TestBase":private]=> + NULL + ["val2"]=> + string(2) "CC" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_006.php b/hphp/test/zend/bad/ext-pdo/pdo_006.php new file mode 100644 index 000000000..654f1ab4e --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_006.php @@ -0,0 +1,19 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'A')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +$stmt = $db->prepare('SELECT val, id from test'); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_GROUP)); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_GROUP)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_006.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_006.php.expectf new file mode 100644 index 000000000..cc972b744 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_006.php.expectf @@ -0,0 +1,46 @@ +array(2) { + ["A"]=> + array(2) { + [0]=> + array(1) { + [0]=> + string(1) "1" + } + [1]=> + array(1) { + [0]=> + string(1) "2" + } + } + ["C"]=> + array(1) { + [0]=> + array(1) { + [0]=> + string(1) "3" + } + } +} +array(2) { + ["A"]=> + array(2) { + [0]=> + array(1) { + ["id"]=> + string(1) "1" + } + [1]=> + array(1) { + ["id"]=> + string(1) "2" + } + } + ["C"]=> + array(1) { + [0]=> + array(1) { + ["id"]=> + string(1) "3" + } + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_007.php b/hphp/test/zend/bad/ext-pdo/pdo_007.php new file mode 100644 index 000000000..ce678963b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_007.php @@ -0,0 +1,19 @@ +exec('CREATE TABLE test(id CHAR(1) NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES('A', 'A')"); +$db->exec("INSERT INTO test VALUES('B', 'A')"); +$db->exec("INSERT INTO test VALUES('C', 'C')"); + +$stmt = $db->prepare('SELECT id, val from test'); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_UNIQUE)); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_007.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_007.php.expectf new file mode 100644 index 000000000..adda34a48 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_007.php.expectf @@ -0,0 +1,34 @@ +array(3) { + ["A"]=> + array(1) { + [0]=> + string(1) "A" + } + ["B"]=> + array(1) { + [0]=> + string(1) "A" + } + ["C"]=> + array(1) { + [0]=> + string(1) "C" + } +} +array(3) { + ["A"]=> + array(1) { + ["val"]=> + string(1) "A" + } + ["B"]=> + array(1) { + ["val"]=> + string(1) "A" + } + ["C"]=> + array(1) { + ["val"]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_008.php b/hphp/test/zend/bad/ext-pdo/pdo_008.php new file mode 100644 index 000000000..64777d74a --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_008.php @@ -0,0 +1,16 @@ +exec('CREATE TABLE test(id CHAR(1) NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES('A', 'A')"); +$db->exec("INSERT INTO test VALUES('B', 'A')"); +$db->exec("INSERT INTO test VALUES('C', 'C')"); + +$stmt = $db->prepare('SELECT val, id from test'); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_UNIQUE)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_008.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_008.php.expectf new file mode 100644 index 000000000..c365124c8 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_008.php.expectf @@ -0,0 +1,12 @@ +array(2) { + ["A"]=> + array(1) { + [0]=> + string(1) "B" + } + ["C"]=> + array(1) { + [0]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_009.php b/hphp/test/zend/bad/ext-pdo/pdo_009.php new file mode 100644 index 000000000..524b5a80f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_009.php @@ -0,0 +1,48 @@ +exec('CREATE TABLE classtypes(id int NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL UNIQUE)'); +$db->exec('INSERT INTO classtypes VALUES(0, \'stdClass\')'); +$db->exec('INSERT INTO classtypes VALUES(1, \'Test1\')'); +$db->exec('INSERT INTO classtypes VALUES(2, \'Test2\')'); +$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, 0, \'A\')'); +$db->exec('INSERT INTO test VALUES(2, 1, \'B\')'); +$db->exec('INSERT INTO test VALUES(3, 2, \'C\')'); +$db->exec('INSERT INTO test VALUES(4, 3, \'D\')'); + +$stmt = $db->prepare('SELECT classtypes.name, test.id AS id, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id'); + +class Test1 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + +class Test2 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + +class Test3 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_NUM)); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE, 'Test3')); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_009.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_009.php.expectf new file mode 100644 index 000000000..44762feb4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_009.php.expectf @@ -0,0 +1,71 @@ +array(4) { + [0]=> + array(3) { + [0]=> + string(8) "stdClass" + [1]=> + string(1) "1" + [2]=> + string(1) "A" + } + [1]=> + array(3) { + [0]=> + string(5) "Test1" + [1]=> + string(1) "2" + [2]=> + string(1) "B" + } + [2]=> + array(3) { + [0]=> + string(5) "Test2" + [1]=> + string(1) "3" + [2]=> + string(1) "C" + } + [3]=> + array(3) { + [0]=> + NULL + [1]=> + string(1) "4" + [2]=> + string(1) "D" + } +} +Test1::__construct() +Test2::__construct() +Test3::__construct() +array(4) { + [0]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(Test2)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } + [3]=> + object(Test3)#%d (2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_010.php b/hphp/test/zend/bad/ext-pdo/pdo_010.php new file mode 100644 index 000000000..b929be456 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_010.php @@ -0,0 +1,49 @@ +exec('CREATE TABLE classtypes(id int NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL UNIQUE)'); +$db->exec('INSERT INTO classtypes VALUES(0, \'stdClass\')'); +$db->exec('INSERT INTO classtypes VALUES(1, \'Test1\')'); +$db->exec('INSERT INTO classtypes VALUES(2, \'Test2\')'); +$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int, val VARCHAR(10), grp VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, 0, \'A\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(2, 1, \'B\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(3, 2, \'C\', \'Group2\')'); +$db->exec('INSERT INTO test VALUES(4, 3, \'D\', \'Group2\')'); + +$stmt = $db->prepare('SELECT classtypes.name, test.grp AS grp, test.id AS id, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id'); + +class Test1 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + +class Test2 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + +class Test3 +{ + public function __construct() + { + echo __METHOD__ . "()\n"; + } +} + + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_GROUP, 'Test3')); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_UNIQUE, 'Test3')); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_010.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_010.php.expectf new file mode 100644 index 000000000..e62b0ee22 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_010.php.expectf @@ -0,0 +1,58 @@ +Test1::__construct() +Test2::__construct() +Test3::__construct() +array(2) { + ["Group1"]=> + array(2) { + [0]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + } + ["Group2"]=> + array(2) { + [0]=> + object(Test2)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } + [1]=> + object(Test3)#%d (2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } + } +} +Test1::__construct() +Test2::__construct() +Test3::__construct() +array(2) { + ["Group1"]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + ["Group2"]=> + object(Test3)#%d (2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_011.php b/hphp/test/zend/bad/ext-pdo/pdo_011.php new file mode 100644 index 000000000..bbdd40c09 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_011.php @@ -0,0 +1,74 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(3, \'C\', \'Group2\')'); +$db->exec('INSERT INTO test VALUES(4, \'D\', \'Group2\')'); + +class DerivedStatement extends PDOStatement +{ + private function __construct($name, $db) + { + $this->name = $name; + echo __METHOD__ . "($name)\n"; + } + + function reTrieve($id, $val) { + echo __METHOD__ . "($id,$val)\n"; + return array($id=>$val); + } +} + +$select1 = $db->prepare('SELECT grp, id FROM test'); +$select2 = $db->prepare('SELECT id, val FROM test'); +$derived = $db->prepare('SELECT id, val FROM test', array(PDO::ATTR_STATEMENT_CLASS=>array('DerivedStatement', array('Overloaded', $db)))); + +class Test1 +{ + public function __construct($id, $val) + { + echo __METHOD__ . "($id,$val)\n"; + $this->id = $id; + $this->val = $val; + } + + static public function factory($id, $val) + { + echo __METHOD__ . "($id,$val)\n"; + return new self($id, $val); + } +} + +function test($id,$val='N/A') +{ + echo __METHOD__ . "($id,$val)\n"; + return array($id=>$val); +} + +$f = new Test1(0,0); + +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_FUNC|PDO::FETCH_GROUP, 'test')); + +$select2->execute(); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, 'test')); + +$select2->execute(); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, array('Test1','factory'))); + +$select2->execute(); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, array($f, 'factory'))); + +var_dump(get_class($derived)); +$derived->execute(); +var_dump($derived->fetchAll(PDO::FETCH_FUNC, array($derived, 'retrieve'))); +$derived->execute(); +var_dump($derived->fetchAll(PDO::FETCH_FUNC, array($derived, 'reTrieve'))); +$derived->execute(); +var_dump($derived->fetchAll(PDO::FETCH_FUNC, array($derived, 'RETRIEVE'))); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_011.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_011.php.expectf new file mode 100644 index 000000000..e915d7950 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_011.php.expectf @@ -0,0 +1,215 @@ +DerivedStatement::__construct(Overloaded) +Test1::__construct(0,0) +test(1,N/A) +test(2,N/A) +test(3,N/A) +test(4,N/A) +array(2) { + ["Group1"]=> + array(2) { + [0]=> + array(1) { + [1]=> + string(3) "N/A" + } + [1]=> + array(1) { + [2]=> + string(3) "N/A" + } + } + ["Group2"]=> + array(2) { + [0]=> + array(1) { + [3]=> + string(3) "N/A" + } + [1]=> + array(1) { + [4]=> + string(3) "N/A" + } + } +} +test(1,A) +test(2,B) +test(3,C) +test(4,D) +array(4) { + [0]=> + array(1) { + [1]=> + string(1) "A" + } + [1]=> + array(1) { + [2]=> + string(1) "B" + } + [2]=> + array(1) { + [3]=> + string(1) "C" + } + [3]=> + array(1) { + [4]=> + string(1) "D" + } +} +Test1::factory(1,A) +Test1::__construct(1,A) +Test1::factory(2,B) +Test1::__construct(2,B) +Test1::factory(3,C) +Test1::__construct(3,C) +Test1::factory(4,D) +Test1::__construct(4,D) +array(4) { + [0]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } + [3]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } +} +Test1::factory(1,A) +Test1::__construct(1,A) +Test1::factory(2,B) +Test1::__construct(2,B) +Test1::factory(3,C) +Test1::__construct(3,C) +Test1::factory(4,D) +Test1::__construct(4,D) +array(4) { + [0]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } + [3]=> + object(Test1)#%d (2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } +} +string(16) "DerivedStatement" +DerivedStatement::reTrieve(1,A) +DerivedStatement::reTrieve(2,B) +DerivedStatement::reTrieve(3,C) +DerivedStatement::reTrieve(4,D) +array(4) { + [0]=> + array(1) { + [1]=> + string(1) "A" + } + [1]=> + array(1) { + [2]=> + string(1) "B" + } + [2]=> + array(1) { + [3]=> + string(1) "C" + } + [3]=> + array(1) { + [4]=> + string(1) "D" + } +} +DerivedStatement::reTrieve(1,A) +DerivedStatement::reTrieve(2,B) +DerivedStatement::reTrieve(3,C) +DerivedStatement::reTrieve(4,D) +array(4) { + [0]=> + array(1) { + [1]=> + string(1) "A" + } + [1]=> + array(1) { + [2]=> + string(1) "B" + } + [2]=> + array(1) { + [3]=> + string(1) "C" + } + [3]=> + array(1) { + [4]=> + string(1) "D" + } +} +DerivedStatement::reTrieve(1,A) +DerivedStatement::reTrieve(2,B) +DerivedStatement::reTrieve(3,C) +DerivedStatement::reTrieve(4,D) +array(4) { + [0]=> + array(1) { + [1]=> + string(1) "A" + } + [1]=> + array(1) { + [2]=> + string(1) "B" + } + [2]=> + array(1) { + [3]=> + string(1) "C" + } + [3]=> + array(1) { + [4]=> + string(1) "D" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_012.php b/hphp/test/zend/bad/ext-pdo/pdo_012.php new file mode 100644 index 000000000..9251d4473 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_012.php @@ -0,0 +1,34 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')'); + +$SELECT = 'SELECT val, grp FROM test'; + +$stmt = $db->query($SELECT, PDO::FETCH_NUM); +var_dump($stmt->fetchAll()); + +class Test +{ + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } +} + +unset($stmt); + +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test'); +var_dump($stmt->fetchAll()); + +unset($stmt); + +$stmt = $db->query($SELECT, PDO::FETCH_NUM); +$stmt->setFetchMode(PDO::FETCH_CLASS, 'Test', array('Changed')); +var_dump($stmt->fetchAll()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_012.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_012.php.expectf new file mode 100644 index 000000000..e99f475a8 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_012.php.expectf @@ -0,0 +1,52 @@ +array(2) { + [0]=> + array(2) { + [0]=> + string(1) "A" + [1]=> + string(6) "Group1" + } + [1]=> + array(2) { + [0]=> + string(1) "B" + [1]=> + string(6) "Group2" + } +} +Test::__construct(N/A) +Test::__construct(N/A) +array(2) { + [0]=> + object(Test)#%d (2) { + ["val"]=> + string(1) "A" + ["grp"]=> + string(6) "Group1" + } + [1]=> + object(Test)#%d (2) { + ["val"]=> + string(1) "B" + ["grp"]=> + string(6) "Group2" + } +} +Test::__construct(Changed) +Test::__construct(Changed) +array(2) { + [0]=> + object(Test)#%d (2) { + ["val"]=> + string(1) "A" + ["grp"]=> + string(6) "Group1" + } + [1]=> + object(Test)#%d (2) { + ["val"]=> + string(1) "B" + ["grp"]=> + string(6) "Group2" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_013.php b/hphp/test/zend/bad/ext-pdo/pdo_013.php new file mode 100644 index 000000000..aab8a28f4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_013.php @@ -0,0 +1,44 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')'); + +$SELECT = 'SELECT val, grp FROM test'; + +$stmt = $db->prepare($SELECT); + +$stmt->execute(); +$stmt->setFetchMode(PDO::FETCH_NUM); +foreach ($stmt as $data) +{ + var_dump($data); +} + +class Test +{ + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } +} + +unset($stmt); + +foreach ($db->query($SELECT, PDO::FETCH_CLASS, 'Test') as $data) +{ + var_dump($data); +} + +unset($stmt); + +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); + +foreach($stmt as $data) +{ + var_dump($data); +} +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_013.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_013.php.expectf new file mode 100644 index 000000000..93a1b2411 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_013.php.expectf @@ -0,0 +1,40 @@ +array(2) { + [0]=> + string(1) "A" + [1]=> + string(6) "Group1" +} +array(2) { + [0]=> + string(1) "B" + [1]=> + string(6) "Group2" +} +Test::__construct(N/A) +object(Test)#%d (2) { + ["val"]=> + string(1) "A" + ["grp"]=> + string(6) "Group1" +} +Test::__construct(N/A) +object(Test)#%d (2) { + ["val"]=> + string(1) "B" + ["grp"]=> + string(6) "Group2" +} +Test::__construct(WOW) +object(Test)#%d (2) { + ["val"]=> + string(1) "A" + ["grp"]=> + string(6) "Group1" +} +Test::__construct(WOW) +object(Test)#%d (2) { + ["val"]=> + string(1) "B" + ["grp"]=> + string(6) "Group2" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_014.php b/hphp/test/zend/bad/ext-pdo/pdo_014.php new file mode 100644 index 000000000..b635bb7ce --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_014.php @@ -0,0 +1,58 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')'); +$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')'); +$SELECT = 'SELECT val, grp FROM test'; + +class Test +{ + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } +} + +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); + +$it = new IteratorIterator($stmt); /* check if we can convert that thing */ + +/*** HINT: If YOU plan to do so remember not to call rewind() -> see below ***/ + +foreach($it as $data) +{ + var_dump($data); +} + +$it->next(); /* must be allowed */ +var_dump($it->current()); /* must return NULL */ +var_dump($it->valid()); /* must return false */ + +class PDOStatementAggregate extends PDOStatement implements IteratorAggregate +{ + private function __construct() + { + echo __METHOD__ . "\n"; + $this->setFetchMode(PDO::FETCH_NUM); + /* default fetch mode is BOTH, so we see if the ctor can overwrite that */ + } + + function getIterator() + { + echo __METHOD__ . "\n"; + $this->execute(); + return new IteratorIterator($this, 'PDOStatement'); + } +} + +$stmt = $db->prepare($SELECT, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementAggregate'))); + +foreach($stmt as $data) +{ + var_dump($data); +} + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_014.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_014.php.expectf new file mode 100644 index 000000000..8161136d9 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_014.php.expectf @@ -0,0 +1,30 @@ +Test::__construct(WOW) +object(Test)#4 (2) { + ["val"]=> + string(1) "A" + ["grp"]=> + string(6) "Group1" +} +Test::__construct(WOW) +object(Test)#6 (2) { + ["val"]=> + string(1) "B" + ["grp"]=> + string(6) "Group2" +} +NULL +bool(false) +PDOStatementAggregate::__construct +PDOStatementAggregate::getIterator +array(2) { + [0]=> + string(1) "A" + [1]=> + string(6) "Group1" +} +array(2) { + [0]=> + string(1) "B" + [1]=> + string(6) "Group2" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_015.php b/hphp/test/zend/bad/ext-pdo/pdo_015.php new file mode 100644 index 000000000..6fbd9ee96 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_015.php @@ -0,0 +1,31 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(20))'); +$db->exec('INSERT INTO test VALUES(1, \'A\', \'A2\')'); +$db->exec('INSERT INTO test VALUES(2, \'A\', \'B2\')'); + +$select1 = $db->prepare('SELECT id, val, val2 FROM test'); +$select2 = $db->prepare('SELECT val, val2 FROM test'); + +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN, 2)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 0)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 1)); +$select1->execute(); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 2)); + +$select2->execute(); +var_dump($select2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_015.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_015.php.expectf new file mode 100644 index 000000000..f338adab1 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_015.php.expectf @@ -0,0 +1,57 @@ +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" +} +array(2) { + [0]=> + string(2) "A2" + [1]=> + string(2) "B2" +} +array(2) { + [1]=> + array(1) { + [0]=> + string(1) "A" + } + [2]=> + array(1) { + [0]=> + string(1) "A" + } +} +array(2) { + [1]=> + string(1) "A" + [2]=> + string(1) "A" +} +array(2) { + [1]=> + string(1) "1" + [2]=> + string(1) "2" +} +array(2) { + [1]=> + string(1) "A" + [2]=> + string(1) "A" +} +array(2) { + [1]=> + string(2) "A2" + [2]=> + string(2) "B2" +} +array(1) { + ["A"]=> + array(2) { + [0]=> + string(2) "A2" + [1]=> + string(2) "B2" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_016.php b/hphp/test/zend/bad/ext-pdo/pdo_016.php new file mode 100644 index 000000000..567c85add --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_016.php @@ -0,0 +1,97 @@ +getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); +} + +$db->exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); +$db->exec('INSERT INTO test VALUES(0, \'String0\')'); +$db->exec('INSERT INTO test VALUES(1, \'String1\')'); +$db->exec('INSERT INTO test VALUES(2, \'String2\')'); + +$stmt1 = $db->prepare('SELECT COUNT(idx) FROM test'); +$stmt2 = $db->prepare('SELECT idx, txt FROM test ORDER by idx'); + +$stmt1->execute(); +var_dump($stmt1->fetchColumn()); +$stmt1 = null; + +$stmt2->execute(); +$cont = $stmt2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); +var_dump($cont); + +echo "===WHILE===\n"; + +$stmt2->bindColumn('idx', $idx); +$stmt2->bindColumn('txt', $txt); +$stmt2->execute(); + +while($stmt2->fetch(PDO::FETCH_BOUND)) { + var_dump(array($idx=>$txt)); +} + +echo "===ALONE===\n"; + +$stmt3 = $db->prepare('SELECT txt FROM test WHERE idx=:inp'); +$stmt3->bindParam(':inp', $idx); /* by foreign name */ + +$stmt4 = $db->prepare('SELECT idx FROM test WHERE txt=:txt'); +$stmt4->bindParam(':txt', $txt); /* using same name */ + +foreach($cont as $idx => $txt) +{ + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt3->bindColumn('txt', $col1); + } + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + + var_dump($stmt4->execute()); + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt4->bindColumn('idx', $col2); + } + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump(array($col2=>$col1)); +} + +echo "===REBIND/SAME===\n"; + +$stmt4->bindColumn('idx', $col1); + +foreach($cont as $idx => $txt) +{ + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + var_dump($col1); + var_dump($stmt4->execute()); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump($col1); +} + +echo "===REBIND/CONFLICT===\n"; + +$stmt2->bindColumn('idx', $col1); +$stmt2->bindColumn('txt', $col1); +$stmt2->execute(); + +while($stmt2->fetch(PDO::FETCH_BOUND)) +{ + var_dump($col1); +} + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_016.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_016.php.expectf new file mode 100644 index 000000000..d62ebe7c4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_016.php.expectf @@ -0,0 +1,94 @@ +string(1) "3" +array(3) { + [0]=> + string(7) "String0" + [1]=> + string(7) "String1" + [2]=> + string(7) "String2" +} +===WHILE=== +array(1) { + [0]=> + string(7) "String0" +} +array(1) { + [1]=> + string(7) "String1" +} +array(1) { + [2]=> + string(7) "String2" +} +===ALONE=== +array(1) { + [0]=> + string(7) "String0" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [0]=> + string(7) "String0" +} +array(1) { + [1]=> + string(7) "String1" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [1]=> + string(7) "String1" +} +array(1) { + [2]=> + string(7) "String2" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [2]=> + string(7) "String2" +} +===REBIND/SAME=== +array(1) { + [0]=> + string(7) "String0" +} +bool(true) +bool(true) +string(7) "String0" +bool(true) +bool(true) +string(1) "0" +array(1) { + [1]=> + string(7) "String1" +} +bool(true) +bool(true) +string(7) "String1" +bool(true) +bool(true) +string(1) "1" +array(1) { + [2]=> + string(7) "String2" +} +bool(true) +bool(true) +string(7) "String2" +bool(true) +bool(true) +string(1) "2" +===REBIND/CONFLICT=== +string(7) "String0" +string(7) "String1" +string(7) "String2" \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_016a.php b/hphp/test/zend/bad/ext-pdo/pdo_016a.php new file mode 100644 index 000000000..98f66a87a --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_016a.php @@ -0,0 +1,97 @@ +getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); +} + +$db->exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); +$db->exec('INSERT INTO test VALUES(0, \'String0\')'); +$db->exec('INSERT INTO test VALUES(1, \'String1\')'); +$db->exec('INSERT INTO test VALUES(2, \'String2\')'); + +$stmt1 = $db->prepare('SELECT COUNT(idx) FROM test'); +$stmt2 = $db->prepare('SELECT idx, txt FROM test ORDER by idx'); + +$stmt1->execute(); +var_dump($stmt1->fetchColumn()); +$stmt1 = null; + +$stmt2->execute(); +$cont = $stmt2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); +var_dump($cont); + +echo "===WHILE===\n"; + +$stmt2->bindColumn('idx', $idx); +$stmt2->bindColumn('txt', $txt); +$stmt2->execute(); + +while($stmt2->fetch(PDO::FETCH_BOUND)) { + var_dump(array($idx=>$txt)); +} + +echo "===ALONE===\n"; + +$stmt3 = $db->prepare('SELECT txt FROM test WHERE idx=:inp'); +$stmt3->bindParam('inp', $idx); /* by foreign name */ + +$stmt4 = $db->prepare('SELECT idx FROM test WHERE txt=:txt'); +$stmt4->bindParam('txt', $txt); /* using same name */ + +foreach($cont as $idx => $txt) +{ + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt3->bindColumn('txt', $col1); + } + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + + var_dump($stmt4->execute()); + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt4->bindColumn('idx', $col2); + } + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump(array($col2=>$col1)); +} + +echo "===REBIND/SAME===\n"; + +$stmt4->bindColumn('idx', $col1); + +foreach($cont as $idx => $txt) +{ + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + var_dump($col1); + var_dump($stmt4->execute()); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump($col1); +} + +echo "===REBIND/CONFLICT===\n"; + +$stmt2->bindColumn('idx', $col1); +$stmt2->bindColumn('txt', $col1); +$stmt2->execute(); + +while($stmt2->fetch(PDO::FETCH_BOUND)) +{ + var_dump($col1); +} + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_016a.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_016a.php.expectf new file mode 100644 index 000000000..d62ebe7c4 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_016a.php.expectf @@ -0,0 +1,94 @@ +string(1) "3" +array(3) { + [0]=> + string(7) "String0" + [1]=> + string(7) "String1" + [2]=> + string(7) "String2" +} +===WHILE=== +array(1) { + [0]=> + string(7) "String0" +} +array(1) { + [1]=> + string(7) "String1" +} +array(1) { + [2]=> + string(7) "String2" +} +===ALONE=== +array(1) { + [0]=> + string(7) "String0" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [0]=> + string(7) "String0" +} +array(1) { + [1]=> + string(7) "String1" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [1]=> + string(7) "String1" +} +array(1) { + [2]=> + string(7) "String2" +} +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + [2]=> + string(7) "String2" +} +===REBIND/SAME=== +array(1) { + [0]=> + string(7) "String0" +} +bool(true) +bool(true) +string(7) "String0" +bool(true) +bool(true) +string(1) "0" +array(1) { + [1]=> + string(7) "String1" +} +bool(true) +bool(true) +string(7) "String1" +bool(true) +bool(true) +string(1) "1" +array(1) { + [2]=> + string(7) "String2" +} +bool(true) +bool(true) +string(7) "String2" +bool(true) +bool(true) +string(1) "2" +===REBIND/CONFLICT=== +string(7) "String0" +string(7) "String1" +string(7) "String2" \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_017.php b/hphp/test/zend/bad/ext-pdo/pdo_017.php new file mode 100644 index 000000000..5e821ecbf --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_017.php @@ -0,0 +1,43 @@ +getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { + require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db); +} else { + $suf = ''; +} + +$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))'.$suf); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); +$delete = $db->prepare('DELETE FROM test'); + +function countRows($action) { + global $db; + $select = $db->prepare('SELECT COUNT(*) FROM test'); + $select->execute(); + $res = $select->fetchColumn(); + return "Counted $res rows after $action.\n"; +} + +echo countRows('insert'); + +$db->beginTransaction(); +$delete->execute(); +echo countRows('delete'); +$db->rollBack(); + +echo countRows('rollback'); + +$db->beginTransaction(); +$delete->execute(); +echo countRows('delete'); +$db->commit(); + +echo countRows('commit'); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_017.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_017.php.expectf new file mode 100644 index 000000000..6bd251b4b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_017.php.expectf @@ -0,0 +1,5 @@ +Counted 3 rows after insert. +Counted 0 rows after delete. +Counted 3 rows after rollback. +Counted 0 rows after delete. +Counted 0 rows after commit. \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_018.php b/hphp/test/zend/bad/ext-pdo/pdo_018.php new file mode 100644 index 000000000..8c91ad881 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_018.php @@ -0,0 +1,151 @@ + $val) { + $serialized[$prop] = $val; + } + $serialized = serialize($serialized); + echo __METHOD__ . "() = '$serialized'\n"; + return $serialized; + } + + function unserialize($serialized) + { + echo __METHOD__ . "($serialized)\n"; + foreach(unserialize($serialized) as $prop => $val) { + $this->$prop = '#'.$val; + } + return true; + } +} + +class TestDerived extends TestBase +{ + public $BasePub = 'DerivedPublic'; + protected $BasePro = 'DerivdeProtected'; + public $DerivedPub = 'Public'; + protected $DerivedPro = 'Protected'; + private $DerivedPri = 'Private'; + + function serialize() + { + echo __METHOD__ . "()\n"; + return TestBase::serialize(); + } + + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + return TestBase::unserialize($serialized); + } +} + +class TestLeaf extends TestDerived +{ +} + +$db->exec('CREATE TABLE classtypes(id int NOT NULL PRIMARY KEY, name VARCHAR(20) NOT NULL UNIQUE)'); +$db->exec('INSERT INTO classtypes VALUES(0, \'stdClass\')'); +$db->exec('INSERT INTO classtypes VALUES(1, \'TestBase\')'); +$db->exec('INSERT INTO classtypes VALUES(2, \'TestDerived\')'); +$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int, val VARCHAR(255))'); + +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +var_dump($db->query('SELECT COUNT(*) FROM classtypes')->fetchColumn()); +var_dump($db->query('SELECT id, name FROM classtypes ORDER by id')->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); + +$objs = array(); +$objs[0] = new stdClass; +$objs[1] = new TestBase; +$objs[2] = new TestDerived; +$objs[3] = new TestLeaf; + +$stmt = $db->prepare('SELECT id FROM classtypes WHERE name=:cname'); +$stmt->bindParam(':cname', $cname); + +$ctypes = array(); + +foreach($objs as $obj) +{ + $cname = get_class($obj); + $ctype = NULL; /* set default for non stored class name */ + $stmt->execute(); + $stmt->bindColumn('id', $ctype); + $stmt->fetch(PDO::FETCH_BOUND); + $ctypes[$cname] = $ctype; +} + +echo "===TYPES===\n"; +var_dump($ctypes); + +unset($stmt); + +echo "===INSERT===\n"; +$stmt = $db->prepare('INSERT INTO test VALUES(:id, :classtype, :val)'); +$stmt->bindParam(':id', $idx); +$stmt->bindParam(':classtype', $ctype); +$stmt->bindParam(':val', $val); + +foreach($objs as $idx => $obj) +{ + $ctype = $ctypes[get_class($obj)]; + if (method_exists($obj, 'serialize')) + { + $val = $obj->serialize(); + } + else + { + $val = ''; + } + $stmt->execute(); +} + +unset($stmt); + +echo "===DATA===\n"; +$res = $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN); + +// For Oracle map NULL to empty string so the test doesn't diff +if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci' && $res[0] === null) { + $res[0] = ""; +} +var_dump($res); + +echo "===FAILURE===\n"; +try +{ + $db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf', array()); +} +catch (PDOException $e) +{ + echo 'Exception:'; + echo $e->getMessage()."\n"; +} + +echo "===COUNT===\n"; +var_dump($db->query('SELECT COUNT(*) FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id WHERE (classtypes.id IS NULL OR classtypes.id > 0)')->fetchColumn()); + +echo "===DATABASE===\n"; +$stmt = $db->prepare('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id WHERE (classtypes.id IS NULL OR classtypes.id > 0)'); + +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + +echo "===FETCHCLASS===\n"; +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf')); + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_018.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_018.php.expectf new file mode 100644 index 000000000..9a5071f4b --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_018.php.expectf @@ -0,0 +1,112 @@ +string(1) "3" +array(3) { + [0]=> + string(8) "stdClass" + [1]=> + string(8) "TestBase" + [2]=> + string(11) "TestDerived" +} +===TYPES=== +array(4) { + ["stdClass"]=> + string(1) "0" + ["TestBase"]=> + string(1) "1" + ["TestDerived"]=> + string(1) "2" + ["TestLeaf"]=> + NULL +} +===INSERT=== +TestBase::serialize() = 'a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}' +TestDerived::serialize() +TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}' +TestDerived::serialize() +TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}' +===DATA=== +array(4) { + [0]=> + string(0) "" + [1]=> + string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" + [2]=> + string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" + [3]=> + string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" +} +===FAILURE=== +Exception:SQLSTATE[HY000]: General error: cannot unserialize class +===COUNT=== +string(1) "3" +===DATABASE=== +array(3) { + [0]=> + array(2) { + ["name"]=> + string(8) "TestBase" + ["val"]=> + string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" + } + [1]=> + array(2) { + ["name"]=> + string(11) "TestDerived" + ["val"]=> + string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" + } + [2]=> + array(2) { + ["name"]=> + NULL + ["val"]=> + string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}" + } +} +===FETCHCLASS=== +TestBase::unserialize(a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}) +TestDerived::unserialize() +TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}) +TestDerived::unserialize() +TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}) +array(3) { + [0]=> + object(TestBase)#%d (3) { + ["BasePub"]=> + string(7) "#Public" + ["BasePro":protected]=> + string(10) "#Protected" + ["BasePri":"TestBase":private]=> + string(8) "#Private" + } + [1]=> + object(TestDerived)#%d (6) { + ["BasePub"]=> + string(14) "#DerivedPublic" + ["BasePro":protected]=> + string(17) "#DerivdeProtected" + ["DerivedPub"]=> + string(7) "#Public" + ["DerivedPro":protected]=> + string(10) "#Protected" + ["DerivedPri":"TestDerived":private]=> + string(7) "Private" + ["BasePri":"TestBase":private]=> + string(8) "#Private" + } + [2]=> + object(TestLeaf)#%d (6) { + ["BasePub"]=> + string(14) "#DerivedPublic" + ["BasePro":protected]=> + string(17) "#DerivdeProtected" + ["DerivedPub"]=> + string(7) "#Public" + ["DerivedPro":protected]=> + string(10) "#Protected" + ["DerivedPri":"TestDerived":private]=> + string(7) "Private" + ["BasePri":"TestBase":private]=> + string(8) "#Private" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_019.php b/hphp/test/zend/bad/ext-pdo/pdo_019.php new file mode 100644 index 000000000..aed32d363 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_019.php @@ -0,0 +1,31 @@ +exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); +$db->exec('INSERT INTO test VALUES(0, \'String0\')'); +$db->exec('INSERT INTO test VALUES(1, \'String1\')'); +$db->exec('INSERT INTO test VALUES(2, \'String2\')'); +$db->exec('INSERT INTO test VALUES(3, \'String3\')'); + + +var_dump($db->query('SELECT COUNT(*) FROM test')->fetchColumn()); + +$stmt = $db->prepare('SELECT idx, txt FROM test ORDER by idx'); + +$stmt->execute(); +$cont = $stmt->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); +var_dump($cont); + +echo "===WHILE===\n"; + +$stmt->bindColumn('idx', $idx); +$stmt->bindColumn('txt', $txt); +$stmt->execute(); + +while($stmt->fetch(PDO::FETCH_BOUND)) { + var_dump(array($idx=>$txt)); +} + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_019.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_019.php.expectf new file mode 100644 index 000000000..8b8ba08d1 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_019.php.expectf @@ -0,0 +1,28 @@ +string(1) "4" +array(4) { + [0]=> + string(7) "String0" + [1]=> + string(7) "String1" + [2]=> + string(7) "String2" + [3]=> + string(7) "String3" +} +===WHILE=== +array(1) { + [0]=> + string(7) "String0" +} +array(1) { + [1]=> + string(7) "String1" +} +array(1) { + [2]=> + string(7) "String2" +} +array(1) { + [3]=> + string(7) "String3" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_020.php b/hphp/test/zend/bad/ext-pdo/pdo_020.php new file mode 100644 index 000000000..f4a6b026a --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_020.php @@ -0,0 +1,19 @@ +exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); +$db->exec("INSERT INTO test VALUES(1, 'A', 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B', 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C', 'C')"); + +foreach (array('SELECT id, val FROM test', 'SELECT id, val, val2 FROM test', 'SELECT COUNT(*) FROM test') as $sql) { + + $stmt = $db->query($sql); + $res = $stmt->columnCount(); + echo "Counted $res columns after $sql.\n"; + $stmt = null; +} + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_020.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_020.php.expectf new file mode 100644 index 000000000..91fb0b2d6 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_020.php.expectf @@ -0,0 +1,3 @@ +Counted 2 columns after SELECT id, val FROM test. +Counted 3 columns after SELECT id, val, val2 FROM test. +Counted 1 columns after SELECT COUNT(*) FROM test. \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_021.php b/hphp/test/zend/bad/ext-pdo/pdo_021.php new file mode 100644 index 000000000..62cfe497e --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_021.php @@ -0,0 +1,45 @@ +getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); +} + +$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$select = $db->prepare('SELECT COUNT(id) FROM test'); + +$data = array( + array('10', 'Abc', 'zxy'), + array('20', 'Def', 'wvu'), + array('30', 'Ghi', 'tsr'), + array('40', 'Jkl', 'qpo'), + array('50', 'Mno', 'nml'), + array('60', 'Pqr', 'kji'), +); + + +// Insert using question mark placeholders +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +foreach ($data as $row) { + $stmt->execute($row); +} +$select->execute(); +$num = $select->fetchColumn(); +echo 'There are ' . $num . " rows in the table.\n"; + +// Insert using named parameters +$stmt2 = $db->prepare("INSERT INTO test VALUES(:first, :second, :third)"); +foreach ($data as $row) { + $stmt2->execute(array(':first'=>($row[0] + 5), ':second'=>$row[1], + ':third'=>$row[2])); +} + +$select->execute(); +$num = $select->fetchColumn(); +echo 'There are ' . $num . " rows in the table.\n"; + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_021.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_021.php.expectf new file mode 100644 index 000000000..a967cffdc --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_021.php.expectf @@ -0,0 +1,2 @@ +There are 6 rows in the table. +There are 12 rows in the table. \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_022.php b/hphp/test/zend/bad/ext-pdo/pdo_022.php new file mode 100644 index 000000000..747f163ab --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_022.php @@ -0,0 +1,39 @@ +exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); +$db->exec('insert2', "INSERT INTO test VALUES(:first, :second, :third)"); + +$data = array( + array('10', 'Abc', 'zxy'), + array('20', 'Def', 'wvu'), + array('30', 'Ghi', 'tsr'), + array('40', 'Jkl', 'qpo'), + array('50', 'Mno', 'nml'), + array('60', 'Pqr', 'kji'), +); + + +// Insert using question mark placeholders +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +foreach ($data as $row) { + $stmt->execute($row); +} + +// Retrieve column metadata for a result set returned by explicit SELECT +$select = $db->query('SELECT id, val, val2 FROM test'); +$meta = $select->getColumnMeta(0); +var_dump($meta); +$meta = $select->getColumnMeta(1); +var_dump($meta); +$meta = $select->getColumnMeta(2); +var_dump($meta); + +// Retrieve column metadata for a result set returned by a function +$select = $db->query('SELECT COUNT(*) FROM test'); +$meta = $select->getColumnMeta(0); +var_dump($meta); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_022.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_022.php.expectf new file mode 100644 index 000000000..d9a7d84f0 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_022.php.expectf @@ -0,0 +1 @@ +The unexpected! \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_023.php b/hphp/test/zend/bad/ext-pdo/pdo_023.php new file mode 100644 index 000000000..321873e00 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_023.php @@ -0,0 +1,65 @@ +test2 = 2; + $this->test2 = 22; + echo __METHOD__ . "()\n"; + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } +} + +class PDODatabaseX extends PDO +{ + public $test1 = 1; + + function __destruct() + { + echo __METHOD__ . "()\n"; + } + + function test() + { + $this->test2 = 2; + var_dump($this->test1); + var_dump($this->test2); + $this->test2 = 22; + } + + function query($sql) + { + echo __METHOD__ . "()\n"; + $stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx'))); + $stmt->execute(); + return $stmt; + } +} + +$db = PDOTest::factory('PDODatabaseX'); +$db->test(); +var_dump($db); + +$db->query('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->query('INSERT INTO test VALUES(0, \'A\')'); +$db->query('INSERT INTO test VALUES(1, \'B\')'); + + +$stmt = $db->query('SELECT val, id FROM test'); +var_dump($stmt); +var_dump($stmt->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); + +$stmt = NULL; +$db = NULL; + + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_023.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_023.php.expectf new file mode 100644 index 000000000..a64f70de5 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_023.php.expectf @@ -0,0 +1,35 @@ +int(1) +int(2) +object(PDODatabaseX)#%d (2) { + ["test1"]=> + int(1) + ["test2"]=> + int(22) +} +PDODatabaseX::query() +PDOStatementX::__construct() +PDOStatementX::__destruct() +PDODatabaseX::query() +PDOStatementX::__construct() +PDOStatementX::__destruct() +PDODatabaseX::query() +PDOStatementX::__construct() +PDOStatementX::__destruct() +PDODatabaseX::query() +PDOStatementX::__construct() +object(PDOStatementX)#%d (3) { + ["test1"]=> + int(1) + ["queryString"]=> + string(24) "SELECT val, id FROM test" + ["test2"]=> + int(22) +} +array(2) { + ["A"]=> + string(1) "0" + ["B"]=> + string(1) "1" +} +PDOStatementX::__destruct() +PDODatabaseX::__destruct() \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_024.php b/hphp/test/zend/bad/ext-pdo/pdo_024.php new file mode 100644 index 000000000..d2599b45e --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_024.php @@ -0,0 +1,20 @@ +exec('create table test (id int, name varchar(10))'); + +$stmt = $db->prepare('insert into test (id, name) values(0, :name)'); +$name = NULL; +$before_bind = $name; +$stmt->bindParam(':name', $name); +if ($name !== $before_bind) { + echo "bind: fail\n"; +} else { + echo "bind: success\n"; +} +var_dump($stmt->execute()); +var_dump($db->query('select name from test where id=0')->fetchColumn()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_024.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_024.php.expectf new file mode 100644 index 000000000..d02f660e9 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_024.php.expectf @@ -0,0 +1,3 @@ +bind: success +bool(true) +NULL \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_025.php b/hphp/test/zend/bad/ext-pdo/pdo_025.php new file mode 100644 index 000000000..d56266141 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_025.php @@ -0,0 +1,50 @@ +exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$data = array( + array('10', 'Abc', 'zxy'), + array('20', 'Def', 'wvu'), + array('30', 'Ghi', 'tsr'), + array('40', 'Jkl', 'qpo'), + array('50', 'Mno', 'nml'), + array('60', 'Pqr', 'kji'), +); + + +// Insert using question mark placeholders +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +foreach ($data as $row) { + $stmt->execute($row); +} + +class Test { + public $id, $val, $val2; +} + +$stmt = $db->prepare('SELECT * FROM test'); +$stmt->setFetchMode(PDO::FETCH_INTO, new Test); +$stmt->execute(); + +foreach($stmt as $obj) { + var_dump($obj); +} + +echo "===FAIL===\n"; + +class Fail { + protected $id; + public $val, $val2; +} + +$stmt->setFetchMode(PDO::FETCH_INTO, new Fail); +$stmt->execute(); + +foreach($stmt as $obj) { + var_dump($obj); +} + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_025.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_025.php.expectf new file mode 100644 index 000000000..9ecb0968f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_025.php.expectf @@ -0,0 +1,50 @@ +object(Test)#%d (3) { + ["id"]=> + string(2) "10" + ["val"]=> + string(3) "Abc" + ["val2"]=> + string(3) "zxy" +} +object(Test)#%d (3) { + ["id"]=> + string(2) "20" + ["val"]=> + string(3) "Def" + ["val2"]=> + string(3) "wvu" +} +object(Test)#%d (3) { + ["id"]=> + string(2) "30" + ["val"]=> + string(3) "Ghi" + ["val2"]=> + string(3) "tsr" +} +object(Test)#%d (3) { + ["id"]=> + string(2) "40" + ["val"]=> + string(3) "Jkl" + ["val2"]=> + string(3) "qpo" +} +object(Test)#%d (3) { + ["id"]=> + string(2) "50" + ["val"]=> + string(3) "Mno" + ["val2"]=> + string(3) "nml" +} +object(Test)#%d (3) { + ["id"]=> + string(2) "60" + ["val"]=> + string(3) "Pqr" + ["val2"]=> + string(3) "kji" +} +===FAIL=== +HipHop Fatal error: %a \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_026.php b/hphp/test/zend/bad/ext-pdo/pdo_026.php new file mode 100644 index 000000000..37d969daf --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_026.php @@ -0,0 +1,66 @@ +dbh = $dbh; + echo __METHOD__ . "()\n"; + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } +} + +class PDODatabase extends PDO +{ + 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 = PDOTest::factory('PDODatabase'); +var_dump(get_class($db)); + +$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +var_dump(get_class($stmt)); +foreach ($data as $row) { + $stmt->execute($row); +} + +unset($stmt); + +$stmt = $db->query('SELECT * FROM test'); +var_dump(get_class($stmt)); +var_dump(get_class($stmt->dbh)); + +foreach($stmt as $obj) { + var_dump($obj); +} + +echo "===DONE===\n"; +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_026.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_026.php.expectf new file mode 100644 index 000000000..94d6774d7 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_026.php.expectf @@ -0,0 +1,33 @@ +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=== +PDOStatementX::__destruct() +PDODatabase::__destruct() \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_027.php b/hphp/test/zend/bad/ext-pdo/pdo_027.php new file mode 100644 index 000000000..76f488c6c --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_027.php @@ -0,0 +1,14 @@ +exec('create table test (id int, name varchar(10))'); +$db->exec("INSERT INTO test (id,name) VALUES(1,'test1')"); +$db->exec("INSERT INTO test (id,name) VALUES(2,'test2')"); + +foreach ($db->query("SELECT * FROM test", PDO::FETCH_LAZY) as $v) { + echo "lazy: " . $v->id.$v->name."\n"; +} +echo "End\n"; +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_027.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_027.php.expectf new file mode 100644 index 000000000..cbedeb045 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_027.php.expectf @@ -0,0 +1,3 @@ +lazy: 1test1 +lazy: 2test2 +End \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_028.php b/hphp/test/zend/bad/ext-pdo/pdo_028.php new file mode 100644 index 000000000..dd6c4a35d --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_028.php @@ -0,0 +1,20 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val1 VARCHAR(10), val2 VARCHAR(10), val3 VARCHAR(10))'); +$stmt = $db->prepare('INSERT INTO test values (1, ?, ?, ?)'); + +$data = array("one", "two", "three"); + +foreach ($data as $i => $v) { + $stmt->bindValue($i+1, $v); +} +$stmt->execute(); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_028.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_028.php.expectf new file mode 100644 index 000000000..8b9110852 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_028.php.expectf @@ -0,0 +1,13 @@ +array(1) { + [0]=> + array(4) { + ["id"]=> + string(1) "1" + ["val1"]=> + string(3) "one" + ["val2"]=> + string(3) "two" + ["val3"]=> + string(5) "three" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_029.php b/hphp/test/zend/bad/ext-pdo/pdo_029.php new file mode 100644 index 000000000..bb54b6d21 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_029.php @@ -0,0 +1,77 @@ +dbh = $dbh; + echo __METHOD__ . "()\n"; + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } + + function execute($params = array()) + { + echo __METHOD__ . "()\n"; + parent::execute(); + } +} + +class PDODatabase extends PDO +{ + 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 = PDOTest::factory('PDODatabase'); +var_dump(get_class($db)); + +$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +var_dump(get_class($stmt)); +foreach ($data as $row) { + $stmt->execute($row); +} + +unset($stmt); + +echo "===QUERY===\n"; + +$stmt = $db->query('SELECT * FROM test'); +var_dump(get_class($stmt)); +var_dump(get_class($stmt->dbh)); + +echo "===FOREACH===\n"; + +foreach($stmt as $obj) { + var_dump($obj); +} + +echo "===DONE===\n"; +exit(0); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_029.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_029.php.expectf new file mode 100644 index 000000000..7964d18b3 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_029.php.expectf @@ -0,0 +1,36 @@ +string(11) "PDODatabase" +string(12) "PDOStatement" +===QUERY=== +PDODatabase::query() +PDOStatementX::__construct() +PDOStatementX::execute() +string(13) "PDOStatementX" +string(11) "PDODatabase" +===FOREACH=== +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=== +PDOStatementX::__destruct() +PDODatabase::__destruct() \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_030.php b/hphp/test/zend/bad/ext-pdo/pdo_030.php new file mode 100644 index 000000000..8c75b6cc3 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_030.php @@ -0,0 +1,78 @@ +dbh = $dbh; + $this->setFetchMode(PDO::FETCH_ASSOC); + echo __METHOD__ . "()\n"; + } + + function __destruct() + { + echo __METHOD__ . "()\n"; + } + + function execute($params = array()) + { + echo __METHOD__ . "()\n"; + parent::execute(); + } +} + +class PDODatabase extends PDO +{ + function __destruct() + { + echo __METHOD__ . "()\n"; + } + + function query($sql) + { + echo __METHOD__ . "()\n"; + return parent::query($sql); + } +} + +$db = PDOTest::factory('PDODatabase'); +var_dump(get_class($db)); + +$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +var_dump(get_class($stmt)); +foreach ($data as $row) { + $stmt->execute($row); +} + +unset($stmt); + +echo "===QUERY===\n"; + +var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS)); +$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatementx', array($db))); +var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS)); +$stmt = $db->query('SELECT * FROM test'); +var_dump(get_class($stmt)); +var_dump(get_class($stmt->dbh)); + +echo "===FOREACH===\n"; + +foreach($stmt as $obj) { + var_dump($obj); +} + +echo "===DONE===\n"; +exit(0); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_030.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_030.php.expectf new file mode 100644 index 000000000..1f6204511 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_030.php.expectf @@ -0,0 +1,49 @@ +string(11) "PDODatabase" +string(12) "PDOStatement" +===QUERY=== +array(1) { + [0]=> + string(12) "PDOStatement" +} +array(2) { + [0]=> + string(13) "PDOStatementX" + [1]=> + array(1) { + [0]=> + object(PDODatabase)#%d (0) { + } + } +} +PDODatabase::query() +PDOStatementX::__construct() +string(13) "PDOStatementX" +string(11) "PDODatabase" +===FOREACH=== +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=== +PDOStatementX::__destruct() +PDODatabase::__destruct() \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_031.php b/hphp/test/zend/bad/ext-pdo/pdo_031.php new file mode 100644 index 000000000..9f53cb6c6 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_031.php @@ -0,0 +1,34 @@ +exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); + +$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); +foreach ($data as $row) { + $stmt->execute($row); +} + +unset($stmt); + +echo "===QUERY===\n"; + +$stmt = $db->query('SELECT * FROM test'); + +foreach(new RecursiveTreeIterator(new RecursiveArrayIterator($stmt->fetchAll(PDO::FETCH_ASSOC)), RecursiveTreeIterator::BYPASS_KEY) as $c=>$v) +{ + echo "$v [$c]\n"; +} + +echo "===DONE===\n"; +exit(0); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_031.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_031.php.expectf new file mode 100644 index 000000000..b927dfe53 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_031.php.expectf @@ -0,0 +1,14 @@ +===QUERY=== +|-Array [0] +| |-10 [id] +| |-Abc [val] +| \-zxy [val2] +|-Array [1] +| |-20 [id] +| |-Def [val] +| \-wvu [val2] +\-Array [2] + |-30 [id] + |-Ghi [val] + \-tsr [val2] +===DONE=== \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_032.php b/hphp/test/zend/bad/ext-pdo/pdo_032.php new file mode 100644 index 000000000..9aa45796f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_032.php @@ -0,0 +1,25 @@ +exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +$db->exec("INSERT INTO test VALUES(1, 'A')"); +$db->exec("INSERT INTO test VALUES(2, 'B')"); +$db->exec("INSERT INTO test VALUES(3, 'C')"); + +// Lower case columns +$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); +$stmt->closeCursor(); + +// Upper case columns +$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER); +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); +$stmt->closeCursor(); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_032.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_032.php.expectf new file mode 100644 index 000000000..1a1ae1a32 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_032.php.expectf @@ -0,0 +1,46 @@ +array(3) { + [0]=> + array(2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + array(2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + array(2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +array(3) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VAL"]=> + string(1) "A" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VAL"]=> + string(1) "B" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VAL"]=> + string(1) "C" + } +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_033.php b/hphp/test/zend/bad/ext-pdo/pdo_033.php new file mode 100644 index 000000000..188a5fedc --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_033.php @@ -0,0 +1,24 @@ +?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + +$quoted = $db->quote($unquoted); + +$len = strlen($unquoted); + +@$db->exec("DROP TABLE test"); + +$db->query("CREATE TABLE test (t char($len))"); +$db->query("INSERT INTO test (t) VALUES($quoted)"); + +$stmt = $db->prepare('SELECT * from test'); +$stmt->execute(); + +print_r($stmt->fetchAll(PDO::FETCH_ASSOC)); + +$db->exec("DROP TABLE test"); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_033.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_033.php.expectf new file mode 100644 index 000000000..ca264670f --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_033.php.expectf @@ -0,0 +1,8 @@ +Array +( + [0] => Array + ( + [t] => !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + ) + +) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_034.php b/hphp/test/zend/bad/ext-pdo/pdo_034.php new file mode 100644 index 000000000..c42ded232 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_034.php @@ -0,0 +1,17 @@ +exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))"); + +for ($i = 0; $i < 5; $i++) { + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); +} + +var_dump($db->query("SELECT a,b FROM test")->fetch(PDO::FETCH_KEY_PAIR)); +var_dump($db->query("SELECT a,b FROM test")->fetchAll(PDO::FETCH_KEY_PAIR)); +var_dump($db->query("SELECT * FROM test")->fetch(PDO::FETCH_KEY_PAIR)); +var_dump($db->query("SELECT a,a FROM test")->fetchAll(PDO::FETCH_KEY_PAIR)); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_034.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_034.php.expectf new file mode 100644 index 000000000..d53146453 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_034.php.expectf @@ -0,0 +1,31 @@ +array(1) { + ["test0"]=> + string(1) "0" +} +array(5) { + ["test0"]=> + string(1) "0" + ["test1"]=> + string(1) "1" + ["test2"]=> + string(1) "2" + ["test3"]=> + string(1) "3" + ["test4"]=> + string(1) "4" +} +HipHop Warning: %a +HipHop Warning: %a +bool(false) +array(5) { + ["test0"]=> + string(5) "test0" + ["test1"]=> + string(5) "test1" + ["test2"]=> + string(5) "test2" + ["test3"]=> + string(5) "test3" + ["test4"]=> + string(5) "test4" +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_035.php b/hphp/test/zend/bad/ext-pdo/pdo_035.php new file mode 100644 index 000000000..f5d9863cd --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_035.php @@ -0,0 +1,12 @@ +exec('CREATE TABLE test (id int)'); +$db->exec('INSERT INTO test VALUES (23)'); + +$stmt = $db->prepare('SELECT id FROM test'); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_LAZY); + +echo get_class($result), "\n"; +var_dump(get_parent_class($result)); +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_035.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_035.php.expectf new file mode 100644 index 000000000..bd9f683e0 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_035.php.expectf @@ -0,0 +1,2 @@ +PDORow +bool(false) \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_036.php b/hphp/test/zend/bad/ext-pdo/pdo_036.php new file mode 100644 index 000000000..3bbc06792 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_036.php @@ -0,0 +1,11 @@ +newInstance(); +var_dump($x); + +$instance = new reflectionclass('pdostatement'); +$x = $instance->newInstance(); +var_dump($x); + +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pdo_036.php.expectf b/hphp/test/zend/bad/ext-pdo/pdo_036.php.expectf new file mode 100644 index 000000000..ce7d34f12 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pdo_036.php.expectf @@ -0,0 +1,6 @@ +object(PDORow)#%d (0) { +} +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + NULL +} \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php b/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php new file mode 100644 index 000000000..919ca6e2d --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php @@ -0,0 +1,15 @@ +exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); +} catch (Exception $e) { + echo "Safely caught " . $e->getMessage() . "\n"; +} + +echo "PHP Didn't crash!\n"; +?> \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php.expectf b/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php.expectf new file mode 100644 index 000000000..b7c3d85a9 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5217.php.expectf @@ -0,0 +1,2 @@ +Safely caught You cannot serialize or unserialize PDO instances +PHP Didn't crash! \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php b/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php new file mode 100644 index 000000000..e067ba35a --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php @@ -0,0 +1,15 @@ +exec("CREATE TABLE test (id int NOT NULL, PRIMARY KEY (id))"); +$db->exec("INSERT INTO test (id) VALUES (1)"); + +function heLLO($row) { + return $row; +} + +foreach ($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_FUNC, 'heLLO') as $row) { + var_dump($row); +} diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php.expectf b/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php.expectf new file mode 100644 index 000000000..783a71723 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5772.php.expectf @@ -0,0 +1 @@ +string(1) "1" \ No newline at end of file diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php b/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php new file mode 100644 index 000000000..c7ec11263 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php @@ -0,0 +1,13 @@ +exec("CREATE TABLE test (id int NOT NULL, PRIMARY KEY (id))"); +$db->exec("INSERT INTO test (id) VALUES (1)"); + +$values = array(1); +var_dump($values); +$stmt = $db->prepare('SELECT * FROM test WHERE id = ?'); +$stmt->execute($values); +var_dump($values); diff --git a/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php.expectf b/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php.expectf new file mode 100644 index 000000000..d21b2a9b6 --- /dev/null +++ b/hphp/test/zend/bad/ext-pdo/pecl_bug_5809.php.expectf @@ -0,0 +1,8 @@ +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/bug47769.php b/hphp/test/zend/good/ext-pdo/bug47769.php new file mode 100644 index 000000000..ef06af3eb --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/bug47769.php @@ -0,0 +1,23 @@ +isProtected(); + $this->isPrivate(); + print $str ."\n"; + } +} + +$test = new test('sqlite::memory:'); +$test->quote('foo'); +$test->isProtected(); + +?> \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/bug47769.php.expectf b/hphp/test/zend/good/ext-pdo/bug47769.php.expectf new file mode 100644 index 000000000..5f5cdb5ce --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/bug47769.php.expectf @@ -0,0 +1,4 @@ +this is a protected method. +this is a private method. +foo +HipHop Fatal error: %a \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/bug_44159.php b/hphp/test/zend/good/ext-pdo/bug_44159.php new file mode 100644 index 000000000..5df0bc852 --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/bug_44159.php @@ -0,0 +1,14 @@ +setAttribute($attr, NULL)); + var_dump($pdo->setAttribute($attr, 1)); + var_dump($pdo->setAttribute($attr, 'nonsense')); +} + +@unlink(__DIR__."/foo.db"); + +?> \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/bug_44159.php.expectf b/hphp/test/zend/good/ext-pdo/bug_44159.php.expectf new file mode 100644 index 000000000..3d04736f4 --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/bug_44159.php.expectf @@ -0,0 +1,13 @@ +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +HipHop Warning: %a +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/pdo_037.php b/hphp/test/zend/good/ext-pdo/pdo_037.php new file mode 100644 index 000000000..2170ae016 --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/pdo_037.php @@ -0,0 +1,10 @@ +foo()); + +?> \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/pdo_037.php.expectf b/hphp/test/zend/good/ext-pdo/pdo_037.php.expectf new file mode 100644 index 000000000..3dad4aedf --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/pdo_037.php.expectf @@ -0,0 +1 @@ +HipHop Fatal error: %a \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/pdorow.php b/hphp/test/zend/good/ext-pdo/pdorow.php new file mode 100644 index 000000000..f8a1a70a0 --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/pdorow.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/hphp/test/zend/good/ext-pdo/pdorow.php.expectf b/hphp/test/zend/good/ext-pdo/pdorow.php.expectf new file mode 100644 index 000000000..3dad4aedf --- /dev/null +++ b/hphp/test/zend/good/ext-pdo/pdorow.php.expectf @@ -0,0 +1 @@ +HipHop Fatal error: %a \ No newline at end of file diff --git a/hphp/tools/import_zend_test.py b/hphp/tools/import_zend_test.py index 405c50b87..8fe576472 100755 --- a/hphp/tools/import_zend_test.py +++ b/hphp/tools/import_zend_test.py @@ -113,7 +113,6 @@ no_import = ( '/ext/mcrypt', '/ext/mysql', '/ext/openssl', - '/ext/pdo', '/ext/pdo_mysql', '/ext/pdo_sqlite', '/ext/pgsql',