How to use SQLite in PHP

Source: Internet
Author: User
SQLite is a small and lightweight database. the supported SQL statements are not inferior to those of other databases. the supported programming languages include Tcl, C #, PHP, and Java, now let's learn how to use SQLite in PHP. 1. how to create a folder: SQ... SQLite is a small and lightweight database. the supported SQL statements are not inferior to those of other databases. the supported programming languages include Tcl, C #, PHP, and Java, now let's learn how to use SQLite in PHP.

1. how to create a folder:

SQLite will automatically determine whether the folder exists. if it does not exist, it will be created.

Try {$ db_conn = new PDO ('sqlite: mydb. sqlite ');} catch (PDOException $ e) {echo 'error';} $ stmt = "create table mytable (id, user )"; $ db_conn-> exec ($ stmt );

II. how to write files:

The usage is similar to that of MySQL.

$ Stmt = "insert into mytable (id, user) VALUES ('1', 'AAA')"; $ db_conn-> exec ($ stmt );

III. how to use data:

The usage is similar to that of MySQL.

$ Something = $ db_conn-> prepare ("SELECT id, user FROM mytable"); $ Something-> execute (); while ($ row = $ Something-> fetch (PDO:: FETCH_ASSOC) {echo $ row ['id']. ':'. $ row ['user']. '';}


Address:

Reprinted at will, but please attach the article address :-)

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.