Home >Backend Development >PHP Tutorial >PHP configuration sqlite database development example_PHP tutorial
Baidu search to download the SqLiteManager tool
PHP5 has been bound to sqlite
1. Manually added PDO driver extension support, add
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
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('test.db'); } } $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