I 've been using PHPmysql all the time. Today, I tried sqlite. From configuring sqlite to using php for connection tests, I found a lot of related resources on the Internet. Due to version changes, there are different opinions, it takes a lot of time. Php5.5.9 is used this time. The following section describes how to configure and use sqlite as a reference. 1. Configure sqlite ::
I 've been using PHPmysql all the time. Today, I tried sqlite. From configuring sqlite to using php for connection tests, I found a lot of related resources on the Internet. Due to version changes, there are different opinions, it takes a lot of time. Php5.5.9 is used this time. The following section describes how to configure and use sqlite as a reference. 1. Configure sqlite ::
I have been using PHP + mysql all the time. Today, I tried sqlite. From configuring sqlite to using php for connection tests, I found a lot of related resources on the Internet. Due to version changes, there are different opinions, it takes a lot of time. Php5.5.9 is used this time. The following section describes how to configure and use sqlite:
1. Configure sqlite:
: Http://www.sqlite.org/download.html
I use win7 64-bit, so I need to download these two files:
Sqlite-shell-win32-x86-3080500.zip
Sqlite-dll-win64-x64-3080500.zip
Decompress the package to obtain the following files: sqlite3.dll 、sqlite3.def?sqlite3.exe
Put the three Files in the same directory, for example, E: \ Program Files (x86) \ sqlite,
Run the CMD command prompt cd to enter the sqlite folder, and only use the command:
Sqlite3 DBName. db
To create a database named DBName,
Use the create Statement on the command line to create a data table.
The following is the source code for successfully connecting to and outputting the database:
The official connection document is used as a correct reference.
Http://www.php.net/manual/zh/class.sqlite3.php
//./Address is the database directory
$ Db = new PDO ('sqlite:./address/test. db ');
$ Db-> beginTransaction ();
// Company is the name of the data table.
$ Something = $ db-> prepare ('select * FROM company ');
$ Something-> execute ();
$ Result = $ something-> fetchAll ();
Echo"
";
Print_r ($ result );
?>