note 80874 added to function.sqlite-query
| From: | helmakil at gmail dot com | Date: | Tue, 05 Feb 2008 09:58:28 +0000 |
| Subject: | note 80874 added to function.sqlite-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135785@lists.php.net to get a copy of this message | ||
I suppose this could be useful for users attempting to use a sqlite database for the first time.
<?php
$database = new SQLiteDatabase($yourfile, 0666, $error);
if (!$database) {
$error = (file_exists($yourfile)) ? "Impossible to open, check permissions" :
"Impossible to create, check permissions";
die($error);
}
$query = $database->query("SELECT name FROM sqlite_master WHERE
type='table'", SQLITE_ASSOC, $query_error); #Lists all tables
if ($query_error)
die("Error: $query_error"); #This means that most probably we catch a syntax error
if (!$query)
die("Impossible to execute query.") #As reported above, this means that the db owner is
different from the web server's one, but we did not commit any syntax mistake.
print $query->numRows();
while ($row = $query->fetch())
print($row['name']."\n");
?>
i suppose that the example above is also useful because it will list all the tables created, giving
also comprehension of what appens when managing a sqlite database in OO mode.
----
Server IP: 213.92.11.19
Probable Submitter: 78.12.204.165
----
Manual Page -- http://www.php.net/manual/en/function.sqlite-query.php
Edit -- https://master.php.net/note/edit/80874
Del: integrated -- https://master.php.net/note/delete/80874/integrated
Del: useless -- https://master.php.net/note/delete/80874/useless
Del: bad code -- https://master.php.net/note/delete/80874/bad+code
Del: spam -- https://master.php.net/note/delete/80874/spam
Del: non-english -- https://master.php.net/note/delete/80874/non-english
Del: in docs -- https://master.php.net/note/delete/80874/in+docs
Del: other reasons-- https://master.php.net/note/delete/80874
Reject -- https://master.php.net/note/reject/80874
Search -- https://master.php.net/manage/user-notes.php