PHP Portable Data Object ( PDO ) has a driver for SQLite database as pdo_sqlite. We can check the support for the driver by using phpinfo().
Use phpinfo() to get PHP installation details, code is here
<?Php
echo phpinfo();
?>
Enabling SQLite database support in PHP using PDO and sqlite3 A1
pdo_sqlite
Part of the output is shown here with PDO SQLite support.
Checking PDO driver support using if - else
To check for different database PDO driver support we can use this code.
<?php
if (!in_array("sqlite",PDO::getAvailableDrivers(),TRUE))
{
throw new PDOException ("Cannot work without a proper database setting up");
}else{
echo "<font color='green'>Database setup is OK</font>";
}
?>
If SQLite dirver support is missing then follow the instructions at php.ini here to enable the support. ( restart web server if php.ini is changed )
Enabling pdo_sqlite support inside php.ini
sqlite3 support
Check phpinfo() to know about sqlite3 library support.
Update or enable sqlite3 library support in your php.ini file.
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery,
and web development at plus2net. The tutorials focus on clear explanations, working
examples, and code that readers can test and adapt while learning.