On 5 Aug 2017, at 10:53am, Edmondo Borasio <[email protected]> wrote:
> Hey, do you know where I can find good instructions on how to use SQLITE in
> PHP?
I used to do that for a living.
First, use the sqlite3 module. Don’t use the PDO module which can access many
types of database. So you should be doing "new SQLite3()" like this:
$db = new SQLite3('mysqlitedb.db');
$results = $db->query('SELECT bar FROM foo');
while ($row = $results->fetchArray()) {
var_dump($row);
}
Second, I have not found any better examples than you find in the documentation
<http://php.net/manual/en/book.sqlite3.php>
which is rather annoying since there aren’t many examples of some calls.
Third, I recommend you try to do object-oriented programming in PHP where
possible, and the sqlite3 module works well with that. So although the call
provided is
$row = $results->fetchArray()
I frequently do
$row = (object) $results->fetchArray()
and the var_dump line in the above example will show you how this changes what
you get.
Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users