sqlite3 和 pdo_sqlite 有什么区别 [英] what is the difference between sqlite3 and pdo_sqlite

查看:66
本文介绍了sqlite3 和 pdo_sqlite 有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 Web 应用程序从 MySQL 迁移到 SQLite 数据库.我发现有两个用于与 sqlite 通信的 PHP 扩展:php_sqlite3.dllphp_pdo_sqlite.dll.

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?

推荐答案

PDO 是 PHP 中数据库连接的包装器.它旨在涵盖大多数数据库管理系统(MySQL、PostgreSQL ...)提供的功能,因此无论使用哪种 DBMS,函数调用都是相同的.参见 http://php.net/manual/en/book.pdo.php.php_pdo_sqlite.dll 允许您使用 PDO 接口访问 SQLite 数据库.

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.

另一个库(php_sqlite3.dll)是它自己的接口,具有不同的函数调用.任何使用它的代码都只能访问 SQLite 数据库.http://php.net/manual/en/book.sqlite3.php

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

您可能会发现 PDO 与 SQLite3 的功能并不完全匹配.也就是说,SQLite3 可能会提供 PDO 无法提供的东西,或者 PDO 具有不做任何事情的功能,因为 SQLite3 无法支持它们.

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.

PDO 的优势在于,如果您想在将来再次切换(您切换一次,因此您可以再次切换),那么您将不必更改太多代码.如果您的 SQL 足够通用,您几乎只需要更改连接语句即可.

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.

这篇关于sqlite3 和 pdo_sqlite 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆