PHP using the PDO Connection sqlite3 configuration sample _php Tips

Source: Internet
Author: User
Tags dsn php database sqlite sqlite format 3 oracle database

The example in this article describes the configuration method that PHP uses for PDO connection sqlite3. Share to everyone for your reference, specific as follows:

Just start using php+sqlite, always thought oneself use is sqlite3, actually is not, PHP starts from PHP5 >=5.3.0 when the default support Sqlite3

Reference to official documents http://www.php.net/manual/zh/sqlite3.open.php

Default method Interface:

public void Sqlite3::open (string $filename [, int $flags = Sqlite3_open_readwrite | Sqlite3_open_create [, String $encryption _key]])

Using PHP to manipulate the database found that PHP is only supported to Sqlite2 by default and does not support the latest version of Sqlite3. If you want to support Sqlite3, you need to use PDO. To use PDO, you need to load the Php_pdo.dll and Php_pdo_sqlite.dll two modules inside the php.ini. As follows:

Extension=php_pdo.dll
Extension=php_pdo_sqlite.dll

If you do not use PDO, even if you open the above parameters, in fact, or use Sqlite2, do not believe you access to see the generated database at the beginning of the file is not prompted:

* * This file contains a SQLite 2.1 database * * *

The following error is reported when the PHP environment does not open the configuration supported above:

Fatal error:call to undefined function sqlite_open ()

sqlite3 Example:

 
 

Verify: View database:

Display in file header:

SQLite format 3***

More explanation can refer to official website: http://cn.php.net/manual/zh/ref.pdo-sqlite.php

More about PHP Interested readers can view the site topics: "PHP based on PDO Operation Database Skills Summary", "Php+oracle Database Programming Skills Summary", "PHP+MONGODB Database Operation Skills Encyclopedia", "PHP object-oriented Programming Program", Summary of PHP string usage, Getting Started tutorial on Php+mysql database operations, and summary of common PHP database operations techniques

I hope this article will help you with the PHP program design.

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.