summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests/sqlite_oo_020.phpt
blob: 49adaea8b1c120693c3b82df2aeb2929f9a47dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--TEST--
sqlite-oo: factory and exception
--INI--
sqlite.assoc_case=0
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("sqlite")) print "skip"; ?>
--FILE--
<?php 
$dbname = tempnam(dirname(__FILE__), "phpsql");
function cleanup() {
	global $db, $dbname;

	$db = NULL;
	unlink($dbname);
}
register_shutdown_function("cleanup");

try {
	$db = sqlite_factory();
} catch(sqlite_exception $err) {
	echo "Message: ".$err->getMessage()."\n";
	echo "File: ".$err->getFile()."\n";
}

$db = sqlite_factory($dbname);

$data = array(
	array (0 => 'one', 1 => 'two'),
	array (0 => 'three', 1 => 'four')
	);

$db->query("CREATE TABLE strings(a VARCHAR, b VARCHAR)");

foreach ($data as $str) {
	$db->query("INSERT INTO strings VALUES('${str[0]}','${str[1]}')");
}

$r = $db->unbuffered_query("SELECT a, b from strings");
while ($r->hasMore()) {
	var_dump($r->current(SQLITE_NUM));
	$r->next();
}
$r = null;
$db = null;
echo "DONE!\n";
?>
--EXPECTF--
Message: sqlite_factory() expects at least 1 parameter, 0 given
File: %ssqlite_oo_020.php
array(2) {
  [0]=>
  string(3) "one"
  [1]=>
  string(3) "two"
}
array(2) {
  [0]=>
  string(5) "three"
  [1]=>
  string(4) "four"
}
DONE!