Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a SQLite3 db with PHP

Tags:

php

sqlite

I'm new to SQLite3 and PHP and was wondering whether and how I could connect to a SQLite3 database with PHP.

How would I get the data from the db and would it be possible to output them on a browser screen? I've been searching the web for a while now, but couldn't find anything.

Thank you.

like image 857
kolip Avatar asked Feb 18 '11 13:02

kolip


People also ask

Does SQLite work with PHP?

PHP provides two SQLite extensions by default since version 5.0. The latest SQLite extension is known as sqlite3 extension that is included in PHP 5.3+. The sqlite3 extension provides an interface for accessing SQLite 3.


1 Answers

<?php $db = new SQLite3('mysqlitedb.db');  $results = $db->query('SELECT bar FROM foo'); while ($row = $results->fetchArray()) {     var_dump($row); } ?> 

Taken from here: PHP: SQLite3::query - Manual

like image 182
marktucks Avatar answered Sep 21 '22 02:09

marktucks