A detailed explanation of the configuration method of PHP SQLite database

Source: Internet
Author: User
Tags ini sqlite sqlite database phpmyadmin

Configuration of the SQLite database
1. Open php.ini
2. Enable Extension=php_sqlite.dll extensions (you need to enable Extension=php_pdo_sqlite.dll extensions if you need to support PDO connections)
3. Restart the Apache server

The more commonly used functions in SQLite

To open or create a database operation: Sqlite_open (the name of the string target database [, the int operates the read-write mode of the database, string returns the error message for the database]); When this method is used, the connection is made if the database specified in the first argument already exists is created automatically if it does not exist; The read-write mode for the second parameter defaults to 0666
Execute SQL Statement operations: Sqlite_query (Resource database connection handle, string SQL statement);//similar to the mysql_query () method in MySQL
Total records in Statistics: Sqlite_num_rows (Resource the dataset resource returned after executing the SQL statement);//similar to the Mysql_num_rows () method in MySQL
The last operation of the data Id:sqlite_last_insert_rowid (resource database connection handle);//similar to the mysql_insert_id () method in MySQL
Returns a dataset pointer to the query result: Sqlite_fetch_array (Resource the handle to the database connection, the dataset resource returned after executing the SQL statement) is similar to the Mysql_fetch_array () method in MySQL
SQLite Database Operations Instance
1. Create a database called newdb
$db =sqlite_open ("newdb.db") or Die (' Create or connect to database failed! ');
2. Create a new table in the NEWDB database called MyTable
Sqlite_query ($db, "CREATE TABLE mytable (uid INT (one) not null PRIMARY KEY, uname VARCHAR (a) NOT null)") or Die (' New table failed! ');
3. Inserting data into the MyTable
Sqlite_query ($db, "insert INTO mytable values (1, ' Tom ')") or Die (' Add data failed! ');
4. Take out all the data in the table and show it.
$val =sqlite_query ($db, "select * from MyTable");
while ($ru =sqlite_fetch_array ($val)) {
Print_r ($RU);
}
5. Close the NEWDB database
Sqlite_close ($DB);

SQLite has a database management tool similar to phpMyAdmin

Sqlitemanager Management SQLite database
  SQLite is a lightweight, file-oriented database that adheres to acid's relational database management system, which consumes low resources, strong scalability, and strong compatibility.
  PHP's relationship with SQLite is like the relationship between ASP and access, access is a file-type database, SQLite is also a file-type database, the characteristics of a file database is not like MySQL, MSSQL, Databases such as Oracle need to be installed separately, using a file type database such as Access or SQLite only need to download the appropriate extension driver package, then put it in the appropriate extended directory, and then configure it to use. Now PHP5 and above versions are built into the SQLite database extension, only to open the expansion in php.ini can be used directly, details reference: PHP5 SQLite database configuration.
  It is said that SQLite's source code package is less than 30,000 lines, add up to less than 300KB, it's "lightweight" and "efficiency" can be imagined.
  Sqlitemanager differs from phpMyAdmin:
  Sqlitemanager does not automatically recognize your database as phpMyAdmin does, before using Sqlitemanager, You need to manually configure the path and name of the database so that you can manage the database under Sqlitemanager.
Sqlitemanager Management SQLite database operation process
  1. Open the Sqlitemanager
  2 in the WAMP environment. Enter the name of the database to manage in the name input box on the home page ( Database name already created)
  3. Click Browse, locate the database file, open
  4. Enter the absolute path of the database file in the path, I am in the d:/www/mydb.db (note the direction of the slash)
  5. Click Save
  so that Sqlitemanager can connect to the newly created database, and you can manage your SQLite database in Sqlitemanager like phpMyAdmin.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.