I’m migrating my web application from MySQL to SQLite database. I found out there are two PHP extensions for communicating with sqlite: php_sqlite3.dll and php_pdo_sqlite.dll.
What extension is better? Or another question: what are the basic differences between these extensions?
Advertisement
Answer
PDO is a wrapper for database connections in PHP. It’s designed to cover the functionality offered by the majority of database management systems (MySQL, PostgreSQL …) So the function calls are all the same no matter which DBMS it’s using. See http://php.net/manual/en/book.pdo.php . php_pdo_sqlite.dll
allows you to use the PDO interface to access a SQLite database.
The other library (php_sqlite3.dll
) is it’s own interface with different function calls. Any code which uses this will only be able to access a SQLite database. http://php.net/manual/en/book.sqlite3.php
You may find that PDO does not perfectly match the functionality of SQLite3. That is SQLite3 may offer things not available through PDO or PDO has functions which do not do anything because SQLite3 can’t support them.
The advantage of PDO is that if you want to switch again in the future (you’re switching once so you may do again) then you will not have to change much code. If you keep your SQL generic enough, you’ll pretty much just have to change the connection statement.