Home >Backend Development >PHP Tutorial >PHP configuration sqlite database development example_PHP tutorial

PHP configuration sqlite database development example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:00:30947browse

php configuration sqlite database development instance

Baidu search to download the SqLiteManager tool

PHP5 has been bound to sqlite
1. Manually added PDO driver extension support, add

in PHP.ini

extension=php_pdo.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite.dll

extension_dir = "C:Program FilesApache Groupphp5ext"

2. In C:Program FilesApache Groupphp5ext ensure there are php_sqlite.dll, php_pdo_sqlite.dll,

php_pdo.dll extension library

3. Restart apache

4. Download SQLitemanager, create a database, save the database named "db.sqlite", and create a table,
Or sqliteadmin

5. Link to SQLite in PHP

Connect to database

The PHP code below shows how to connect to an existing database. If the database does not exist, then it will be created (created in the application directory by default, for example: php application directory), and finally a database object will be returned.

<!--?php
   class MyDB extends SQLite3
   {
      function __construct()
      {
         $this--->open(&#39;test.db&#39;);
      }
   }
   $db = new MyDB();
   if(!$db){
      echo $db->lastErrorMsg();
   } else {
      echo "Opened database successfully\n";
   }
?>

Now, let’s run the above program to create our database test.db in the current directory. You can change the path as needed. If the database is created successfully, the message shown below is displayed:

Open database successfully

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973375.htmlTechArticlephp configuration sqlite database development example Baidu search download SqLiteManager tool PHP5 has been bound to sqlite 1. Manually added php pdo Driver extension support, add extension=ph...
in PHP.ini
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn