网站大量收购闲置独家精品文档,联系QQ:2885784924

PHP Data Objects Layer (PDO):PHP数据对象层(PDO).ppt

PHP Data Objects Layer (PDO):PHP数据对象层(PDO).ppt

  1. 1、本文档共41页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
PHP Data Objects Layer (PDO):PHP数据对象层(PDO)

PHP Data Objects Layer (PDO) Ilia Alshanetsky What is PDO Common interface to any number of database systems. Written in C, so you know it’s FAST! Designed to make use of all the PHP 5.1 features to simplify interface. Why is it needed? Current state of affairs: Many native database extensions that are similar but do not provide the same interface. In most cases, very old code that does not even scratch the surface of what PHP can offer. In many instances does not account for all the capabilities offered by the database. Ex. SQLite, MySQL extensions What Databases are Supported? At this time PDO offers the following drivers: MySQL 3,4,5 (depends on client libs) PostgreSQL SQLite 2 3 ODBC DB2 Oracle Firebird FreeTDS/Sybase/MSSQL Installing PDO PDO is divided into two components CORE (provides the interface) DRIVERS (access to particular database) Ex. pdo_mysql The CORE is enabled by default, drivers with the exception of pdo_sqlite are not. Actual Install Steps PECL Way pecl install pdo_[driver_name] Update php.ini and add extension=pdo_[driver_name].so (or .dll on win32) Built into PHP ./configure –with-pdo-[driver_name] For Win32 dlls for each driver are available. Using PDO As is the case with all database interfaces, the 1st step involves establishing a connection. What if the Connection Fails? As is the case with most native PHP objects, instantiation failure lead to an exception being thrown. Persistent Connections Connecting to complex databases like Oracle is a slow process, it would be nice to re-use a previously opened connection. DSN INI Tricks The DSN string can be an INI setting and you can “name” as many DSNs are you like. Let’s Run Some Queries Query execution in PDO can be done in two ways Prepared Statements (recommended for speed security) Direct Execution Direct Query Execution Queries that modify information need to be run via exec() method. The return value is the number of rows affected by the operation or FALSE on error. Direc

文档评论(0)

skvdnd51 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档