sqlite_factory
(PHP 5 < 5.4.0)
sqlite_factory — Opens an SQLite database and returns an SQLiteDatabase object
Description
$filename
[, int $mode
= 0666
[, string &$error_message
]] ) : SQLiteDatabasesqlite_factory() behaves similarly to sqlite_open() in that it opens an SQLite database or attempts to create it if it does not exist. However, a SQLiteDatabase object is returned rather than a resource. Please see the sqlite_open() reference page for further usage and caveats.
Parameters
-
filename
-
The filename of the SQLite database.
-
mode
-
The mode of the file. Intended to be used to open the database in read-only mode. Presently, this parameter is ignored by the sqlite library. The default value for mode is the octal value 0666 and this is the recommended value.
-
error_message
-
Passed by reference and is set to hold a descriptive error message explaining why the database could not be opened if there was an error.
Examples
Example #1 sqlite_factory() example
<?php
$dbhandle = sqlite_factory('sqlitedb');
$dbhandle->query('SELECT user_id, username FROM users');
/* functionally equivalent to: */
$dbhandle = new SQLiteDatabase('sqlitedb');
$dbhandle->query('SELECT user_id, username FROM users');
?>
See Also
- sqlite_open() - Opens an SQLite database and create the database if it does not exist
- sqlite_popen() - Opens a persistent handle to an SQLite database and create the database if it does not exist
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.sqlite-factory.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.