xref: /PHP-5.3/ext/sqlite/sqlite.php (revision f60d104c)
1<?php
2if (!extension_loaded("sqlite")) {
3	dl("sqlite.so");
4	if (!extension_loaded("sqlite")) {
5		exit("Please enable SQLite support\n");
6	}
7}
8
9debug_zval_dump(sqlite_libversion());
10debug_zval_dump(sqlite_libencoding());
11
12$s = sqlite_open("weztest.sqlite", 0666, $err);
13
14debug_zval_dump($err);
15debug_zval_dump($s);
16
17$r = sqlite_query("create table foo (a INTEGER PRIMARY KEY, b INTEGER )", $s);
18debug_zval_dump(sqlite_last_error($s));
19debug_zval_dump(sqlite_error_string(sqlite_last_error($s)));
20
21$r = sqlite_query("select *, php('md5', sql) as o from sqlite_master", $s);
22debug_zval_dump($r);
23debug_zval_dump(sqlite_num_rows($r));
24debug_zval_dump(sqlite_num_fields($r));
25
26for ($j = 0; $j < sqlite_num_fields($r); $j++) {
27	echo "Field $j is " . sqlite_field_name($r, $j) . "\n";
28}
29
30while ($row = sqlite_fetch_array($r, SQLITE_ASSOC)) {
31	print_r($row);
32}
33
34sqlite_close($s);
35
36?>
37