1--TEST-- 2sqlite-oo: factory and exception 3--INI-- 4sqlite.assoc_case=0 5--SKIPIF-- 6<?php # vim:ft=php 7if (!extension_loaded("sqlite")) print "skip"; ?> 8--FILE-- 9<?php 10$dbname = tempnam(dirname(__FILE__), "phpsql"); 11function cleanup() { 12 global $db, $dbname; 13 14 $db = NULL; 15 unlink($dbname); 16} 17register_shutdown_function("cleanup"); 18 19try { 20 $db = sqlite_factory(); 21} catch(SQLiteException $err) { 22 echo "Message: ".$err->getMessage()."\n"; 23 echo "File: ".$err->getFile()."\n"; 24 //echo "Line: ".$err->getLine()."\n"; 25 //print_r($err->getTrace()); 26 //echo "BackTrace: ".$err->getTraceAsString()."\n"; 27} 28 29$db = sqlite_factory($dbname); 30 31$data = array( 32 array (0 => 'one', 1 => 'two'), 33 array (0 => 'three', 1 => 'four') 34 ); 35 36$db->query("CREATE TABLE strings(a VARCHAR, b VARCHAR)"); 37 38foreach ($data as $str) { 39 $db->query("INSERT INTO strings VALUES('${str[0]}','${str[1]}')"); 40} 41 42$r = $db->unbufferedQuery("SELECT a, b from strings"); 43while ($r->valid()) { 44 var_dump($r->current(SQLITE_NUM)); 45 $r->next(); 46} 47$r = null; 48$db = null; 49echo "DONE!\n"; 50?> 51--EXPECTF-- 52Message: sqlite_factory() expects at least 1 parameter, 0 given 53File: %ssqlite_oo_020.php 54array(2) { 55 [0]=> 56 string(3) "one" 57 [1]=> 58 string(3) "two" 59} 60array(2) { 61 [0]=> 62 string(5) "three" 63 [1]=> 64 string(4) "four" 65} 66DONE! 67