2003-06-22 17:19:46 +00:00
|
|
|
--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;
|
|
|
|
|
2003-06-22 19:03:24 +00:00
|
|
|
$db = NULL;
|
2003-06-22 17:19:46 +00:00
|
|
|
unlink($dbname);
|
|
|
|
}
|
|
|
|
register_shutdown_function("cleanup");
|
|
|
|
|
|
|
|
try {
|
|
|
|
$db = sqlite_factory();
|
2004-03-29 19:49:17 +00:00
|
|
|
} catch(SQLiteException $err) {
|
2003-09-04 14:54:53 +00:00
|
|
|
echo "Message: ".$err->getMessage()."\n";
|
|
|
|
echo "File: ".$err->getFile()."\n";
|
2004-03-19 20:00:18 +00:00
|
|
|
//echo "Line: ".$err->getLine()."\n";
|
|
|
|
//print_r($err->getTrace());
|
|
|
|
//echo "BackTrace: ".$err->getTraceAsString()."\n";
|
2003-06-22 17:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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]}')");
|
|
|
|
}
|
|
|
|
|
2004-03-26 21:16:50 +00:00
|
|
|
$r = $db->unbufferedQuery("SELECT a, b from strings");
|
2004-03-08 17:33:31 +00:00
|
|
|
while ($r->valid()) {
|
2003-06-22 17:19:46 +00:00
|
|
|
var_dump($r->current(SQLITE_NUM));
|
|
|
|
$r->next();
|
|
|
|
}
|
2003-12-05 13:42:04 +00:00
|
|
|
$r = null;
|
|
|
|
$db = null;
|
2003-06-22 17:19:46 +00:00
|
|
|
echo "DONE!\n";
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
Message: sqlite_factory() expects at least 1 parameter, 0 given
|
2003-12-05 13:42:04 +00:00
|
|
|
File: %ssqlite_oo_020.php
|
2003-06-22 17:19:46 +00:00
|
|
|
array(2) {
|
|
|
|
[0]=>
|
|
|
|
string(3) "one"
|
|
|
|
[1]=>
|
|
|
|
string(3) "two"
|
|
|
|
}
|
|
|
|
array(2) {
|
|
|
|
[0]=>
|
|
|
|
string(5) "three"
|
|
|
|
[1]=>
|
|
|
|
string(4) "four"
|
|
|
|
}
|
|
|
|
DONE!
|
2005-08-16 15:09:51 +00:00
|
|
|
--UEXPECTF--
|
|
|
|
Message: sqlite_factory() expects at least 1 parameter, 0 given
|
|
|
|
File: %ssqlite_oo_020.php
|
|
|
|
array(2) {
|
|
|
|
[0]=>
|
|
|
|
unicode(3) "one"
|
|
|
|
[1]=>
|
|
|
|
unicode(3) "two"
|
|
|
|
}
|
|
|
|
array(2) {
|
|
|
|
[0]=>
|
|
|
|
unicode(5) "three"
|
|
|
|
[1]=>
|
|
|
|
unicode(4) "four"
|
|
|
|
}
|
|
|
|
DONE!
|