Connect SQLite3 Database with PHP

To connect SQLite Database(generally used in Mobile Devices) with PHP environment, then we simply need to do following:

<?php

//SQLite Class is provided my PHP itself, so no need to add any extension.

$db = new SQLite3(‘./db/employees_db.sqlite’); // Path to your SQLite DB

$results = $db->query(‘SELECT * FROM employees LIMIT 10’);
echo “<pre>”;
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
print_r($row);
}

?>


					
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s