On 5 Aug 2017, at 10:10pm, J. King <jk...@jkingweb.ca> wrote:

> Simon, why would you recommend not using PDO? Does the SQLite3 extension 
> perform better, or does it boil down to personal preference?

Good question.  Please allow me slight simplification in the following.

PHP’s SQLite3 extension is a thin shim over SQLite3’s C API.  One PHP method 
for each C call.  It’s the least amount of code you can write to let PHP issue 
SQLite3 calls.  Because of this, it’s extremely fast and uses very little 
memory.  Best of all, if you need documentation for the PHP commands you can 
usually read the documentation for SQLite3’s C API, and in your head convert C 
types to PHP types, etc..

If you know how SQLite3 works then you’ll understand PHP’s SQLite3 extension, 
and it’s the fastest, most efficient way to program.

The PDO extension has to make all commands, types and structures conform to the 
ones already chosen for the PDO extension.  Some of them don’t fit the SQLite 
way of doing things.  For instance, there’s no way of doing the individual 
parts of prepare, step, finalize.  Other commands automatically convert their 
results into different types, taking longer than necessary, using extra memory, 
and losing some distinctions which are important to figure out exactly what’s 
in a SQLite3 database.

However, if you’re already good at PHP, aren’t short of runtime or memory, 
don’t care about picky details of how SQLite works, and/or may want to swap 
between SQLite and a different DBMS, PDO is the way to go.

So it’s horses for courses.  I do keep my eye open for people who say they’re 
using multiple different DBMSes but in the absence of that I generally 
recommend using the SQLite3 module.

sqlite-users mailing list

Reply via email to