|
sqlite_open
Opens a SQLite database and create the database if it does not exist
(PHP 5, PECL sqlite:1.0-1.0.3)
Object oriented style (constructor): SQLiteDatabase { Opens a SQLite database or creates the database if it does not exist. Parameters
ExamplesExample 2338. sqlite_open() example<?php Notes
Tip:
On Unix platforms, SQLite is sensitive to scripts that use the fork() system call. If you
do have such a script, it is recommended that you close the handle prior
to forking and then re-open it in the child and/or parent.
For more information on this issue, see
» The C language interface
to the SQLite library in the section entitled
Tip:
It is not recommended to work with SQLite databases mounted on NFS partitions. Since NFS is notoriously bad when it comes to locking you may find that you cannot even open the database at all, and if it succeeds, the locking behaviour may be undefined.
Note:
Starting with SQLite library version 2.8.2, you can specify
Note:
SQLite is safe mode and open_basedir aware.
See Also
Code Examples / Notes » sqlite_open15-nov-2006 10:45
the above example dows not! work since sqlite_query() does not accept one argument, but only 2. so correct is: <?php if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) { sqlite_query($db,'CREATE TABLE foo (bar varchar(10))'); sqlite_query($db,"INSERT INTO foo VALUES ('fnord')"); $result = sqlite_query($db,'select bar from foo'); var_dump(sqlite_fetch_array($result)); } else { die ($sqliteerror); } ?> ivoras
Since sqlite uses a journal to do updates and inserts (and creates it on the fly), you ALSO must have write permissions set for the web server to write in the same DIRECTORY as the database file.
phillip berndt
If you miss to set the permissions mentioned by ivoras Sqlite will drop an error message saying "Malformed database scheme", which is somehow misleading. (I mentioned this as some [I did] might search php.net for this error message) |
Change Languagesqlite_array_query sqlite_busy_timeout sqlite_changes sqlite_close sqlite_column sqlite_create_aggregate sqlite_create_function sqlite_current sqlite_error_string sqlite_escape_string sqlite_exec sqlite_factory sqlite_fetch_all sqlite_fetch_array sqlite_fetch_column_types sqlite_fetch_object sqlite_fetch_single sqlite_fetch_string sqlite_field_name sqlite_has_more sqlite_has_prev sqlite_key sqlite_last_error sqlite_last_insert_rowid sqlite_libencoding sqlite_libversion sqlite_next sqlite_num_fields sqlite_num_rows sqlite_open sqlite_popen sqlite_prev sqlite_query sqlite_rewind sqlite_seek sqlite_single_query sqlite_udf_decode_binary sqlite_udf_encode_binary sqlite_unbuffered_query sqlite_valid |