Php getting started with sqlite database _ PHP Tutorial

Source: Internet
Author: User
Php reads the sqlite database entry instance. Example of how php reads the sqlite database, and how to operate the sqlite getting started instance in php programming. original article reference: www.jbxue.comarticlephp22383.html before using SQLite, make sure php. in ini, you have started php to read the sqlite database. in php programming, you can operate the sqlite getting started instance.
Reference: http://www.jbxue.com/article/php/22383.html
Before using SQLite, make sure that the sqlite and pdo configurations are enabled in php. ini.

Open the PHP. ini file and perform the following extensions:
Extension = php_pdo.dll

Extension = php_pdo_sqlite.dll
Extension = php_sqlite.dll
The sqlite_open command is used to open a database file.
If no file exists, it is created.

Sqlite_query can execute SQL statements.
Create a table and insert data.

Sqlite_unbuffered_query issues a SELECT statement.
Loop and display results.

Unable to open a temporary database file for storing temporary tables
The temporary database file storing temporary tables cannot be opened. in Windows, if the above error occurs,
Use putenv ("TMP = C:/temp"); to specify a temporary folder.

For details, see the code:

 ";}; // Close the database sqlite_close ($ db) ;}else {print $ sqliteerror ;}?>

PHP + SQLite database operation tutorial and example

 ';} Else {echo' successfully connected the SQlite file: ', $ db_name ,'
';} // CREATE a data TABLE: MD5 password TABLE sqlite_query ($ db, "create table md5 (s int (4) primary key, d varchar (32 ))"); // Insert record $ s = 0; while ($ s <= 999999) {$ d = md5 ($ s); sqlite_query ($ db, "insert into md5 VALUES ($ s, '{$ d}')"); $ s ++;} // retrieve all records $ result = sqlite_query ($ db, 'select * FROM md5'); echo'
';while ($row = sqlite_fetch_array($result, SQLITE_BOTH)) {echo 'Md5:',$row['d'],' Src:',$row['s'], '
';}echo '
'; // Close the SQLite connection sqlite_close ($ db);?>

Php read sqlite entry edition

 Query ('select BottleEncryptUsrName from bottletable4'); // Print the obtained result foreach ($ result as $ row) {echo $ row [0]; echo"
";}?>

Before using SQLite, make sure that php. ini has started...

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.