Enable SQLite in PHP

Source: Internet
Author: User

PHP version 5.0 or later, open from PhP. ini:

Php_sqlite.dll

Php_pdo.dll

Php_pdo_sqlite.dll

 

Restart.

 

Check whether it is successful:

<? PHP

$ Db = sqlite_open ("DB. SQLite"); // open the DB. SQLite database, slite2 type. If it does not exist, try to create it.
Sqlite_query ($ db, "Drop table test ");
Sqlite_query ($ db, "create table test (ID integer primary key, Name text);"); // create a test table. The ID field is the auto-incrementing primary key.
Sqlite_query ($ db, "insert into test (name) values ('hello');"); // insert a row of content
Sqlite_query ($ db, "insert into test (name) values ('World');"); // insert a row of content

Sqlite_close ($ dB );

?>

 

A good SQLite database management software: sqliteadmin

Official Address: http://sqliteadmin.orbmu2k.de

 

 

PhP5 only supports direct sqlite2 operations. For sqlite3, PDO operations are available.

Example:

<?

$ DBH = new PDO ('sqlite: sign. db ');
If (! $ DBH ){
Echo 'err ';
Exit;
}
$ Something = $ DBH-> prepare ('select * From 'sign' limit 0, 10 ');
$ Something-> execute ();
$ Result = $ something-> fetchall ();
Echo '<Table>
<Tr>
<TD> name </TD>
<TD> city </TD>
<TD> content </TD>
</Tr> ';
Foreach ($ result as $ sign ){
Echo "<tr>
<TD >{$ sign ['name']} </TD>
<TD >{$ sign ['city']} </TD>
<TD >{$ sign ['content']} </TD>
}
Echo '</table> ';

Unset ($ DBH );

?>

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.