我正在将我的 Web 应用程序从 MySQL 迁移到 SQLite 数据库。我发现有两个用于与 sqlite 通信的 PHP 扩展:php_sqlite3.dll和php_pdo_sqlite.dll。
什么扩展更好?或者另一个问题:这些扩展之间的基本区别是什么?
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.