PHP uses PDO to connect Sqlite3 configuration method

Source: Internet
Author: User
Tags dsn sqlite format 3
This article mainly introduces the use of the PDO connection Sqlite3 configuration method, combined with the case form a more detailed analysis of PHP based on PDO operation Sqlite3 related considerations, the need for friends can refer to the following

Just started using Php+sqlite, always think that they use sqlite3, actually not, PHP php5 >=5.3.0 from the time to start the default support Sqlite3

Refer to Official Document http://www.php.net/manual/zh/sqlite3.open.php

The default method interface:

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

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

Extension=php_pdo.dllextension=php_pdo_sqlite.dll

If you do not use PDO, even if you open the above parameters, in fact, still use sqlite2, do not believe you access to see the generated database at the beginning of the file is not a hint:

* * This file contains an 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:

In the file header display:

SQLite format 3***

Summary: The above is the entire content of this article, I hope to be able to help you learn.

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.