diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt index 0a3dfbf0894..86c9ce86367 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(2) { ["id"]=> @@ -42,12 +42,5 @@ array(4) { ["val"]=> string(1) "C" } - [3]=> - array(2) { - ["id"]=> - string(1) "4" - ["val"]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt index 187085a9f6b..227f738df76 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_NUM)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(2) { [0]=> @@ -42,12 +42,5 @@ array(4) { [1]=> string(1) "C" } - [3]=> - array(2) { - [0]=> - string(1) "4" - [1]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt index 82d9b37e1a3..e7cffae940a 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_BOTH)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(4) { ["id"]=> @@ -54,16 +54,5 @@ array(4) { [1]=> string(1) "C" } - [3]=> - array(4) { - ["id"]=> - string(1) "4" - [0]=> - string(1) "4" - ["val"]=> - string(1) "D" - [1]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt new file mode 100755 index 00000000000..2e6e93d920d --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt @@ -0,0 +1,46 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_OBJ +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test(id int 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->query('SELECT * FROM test'); + +var_dump($stmt->fetchAll(PDO_FETCH_OBJ)); +?> +===DONE=== + +--EXPECTF-- +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" + } +} +===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt new file mode 100755 index 00000000000..9ea9e2b00b4 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt @@ -0,0 +1,122 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_CLASS +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test(id int 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")'); + +class TestBase +{ + public $id; + public $val; +} + +class TestDerived extends TestBase +{ + protected $p1; + protected $p2; + + public function __construct($p1, $p2) + { + $this->p1 = $p1; + $this->p2 = $p2; + } +} + +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS)); +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestBase')); +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestDerived', array(1,2))); +?> +===DONE=== + +--EXPECTF-- +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" + } +} +array(3) { + [0]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +array(3) { + [0]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +===DONE===