xref: /PHP-5.3/ext/sqlite/tests/sqlite_oo_024.phpt (revision 610c7fbe)
1--TEST--
2sqlite-oo: sqlite::fetch_object
3--INI--
4sqlite.assoc_case=0
5--SKIPIF--
6<?php # vim:ft=php
7if (!extension_loaded("sqlite")) print "skip"; ?>
8--FILE--
9<?php
10include "blankdb_oo.inc";
11
12class class24 {
13	function __construct() {
14		echo __METHOD__ . "\n";
15	}
16}
17
18$data = array(
19	"one",
20	"two",
21	"three"
22	);
23
24$db->query("CREATE TABLE strings(a)");
25
26foreach ($data as $str) {
27	$db->query("INSERT INTO strings VALUES('$str')");
28}
29
30echo "====class24====\n";
31$res = $db->query("SELECT a FROM strings", SQLITE_ASSOC);
32while ($res->valid()) {
33	var_dump($res->fetchObject('class24'));
34}
35
36echo "====stdclass====\n";
37$res = $db->query("SELECT a FROM strings", SQLITE_ASSOC);
38while ($res->valid()) {
39	var_dump($res->fetchObject());
40}
41
42echo "====DONE!====\n";
43?>
44--EXPECTF--
45====class24====
46class24::__construct
47object(class24)#%d (1) {
48  ["a"]=>
49  string(3) "one"
50}
51class24::__construct
52object(class24)#%d (1) {
53  ["a"]=>
54  string(3) "two"
55}
56class24::__construct
57object(class24)#%d (1) {
58  ["a"]=>
59  string(5) "three"
60}
61====stdclass====
62object(stdClass)#%d (1) {
63  ["a"]=>
64  string(3) "one"
65}
66object(stdClass)#%d (1) {
67  ["a"]=>
68  string(3) "two"
69}
70object(stdClass)#%d (1) {
71  ["a"]=>
72  string(5) "three"
73}
74====DONE!====
75