设为首页 收藏本站
查看: 558|回复: 0

[经验分享] PHP-PDO

[复制链接]

尚未签到

发表于 2015-8-27 08:57:26 | 显示全部楼层 |阅读模式
  PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is not an abstraction layer like PearDB. PDO is a more like a data access layer which uses a unified API (Application Programming Interface).
  

How to enable PDO
  
  To enable PDO, configure --enable-pdo and --with-pdo-sqlite --with-pdo-mysql or whatever database needs supporting by PDO (see the PHP manual for more information).
  Installing PDO on Unix systems



  • PDO and the PDO_SQLITE driver is enabled by default as of PHP 5.1.0. You may need to enable the PDO driver for your database of choice; consult the documentation for database-specific PDO drivers to find out more about that.


  • When installing PDO as a shared module, the php.ini file needs to be updated so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step.





    extension=pdo.so
  
  [iyunv@DBSVR01 e]# yum list pdo
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: ftp.twaren.net
Error: No matching Packages to list
[iyunv@DBSVR01 e]# yum search pdo
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: ftp.twaren.net
====================================================================================== N/S Matched: pdo =======================================================================================
php-pdo.i686 : A database access abstraction module for PHP applications
  Name and summary matches only, use "search all" for everything.
[iyunv@DBSVR01 e]#
  
  [iyunv@DBSVR01 e]# yum install php-pdo.i686
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: ftp.twaren.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-pdo.i686 0:5.3.3-22.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================================================
Package                                       Arch                                       Version                                             Repository                                  Size
===============================================================================================================================================================================================
Installing:
php-pdo                                       i686                                       5.3.3-22.el6                                        base                                        74 k
Transaction Summary
===============================================================================================================================================================================================
Install       1 Package(s)
Total download size: 74 k
Installed size: 150 k
Is this ok [y/N]: y
Downloading Packages:
php-pdo-5.3.3-22.el6.i686.rpm                                                                                                                                           |  74 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-pdo-5.3.3-22.el6.i686                                                                                                                                                   1/1
  Verifying  : php-pdo-5.3.3-22.el6.i686                                                                                                                                                   1/1
Installed:
  php-pdo.i686 0:5.3.3-22.el6                                                                                                                                                                  
Complete!
[iyunv@DBSVR01 e]#
  [iyunv@DBSVR01 e]# php check_configuration.php
********************************
*                              *
*  symfony requirements check  *
*                              *
********************************
php.ini used by PHP: /etc/php.ini
** WARNING **
*  The PHP CLI can use a different php.ini file
*  than the one used with your web server.
*  If this is the case, please launch this
*  utility from your web server.
** WARNING **
** Mandatory requirements **
  OK        PHP version is at least 5.2.4 (5.3.3)
** Optional checks **
  OK        PDO is installed
  OK        PDO has some drivers installed: sqlite
[[WARNING]] PHP-XML module is installed: FAILED
            *** Install and enable the php-xml module (required by Propel) ***
[[WARNING]] XSL module is installed: FAILED
            *** Install and enable the XSL module (recommended for Propel) ***
  OK        The token_get_all() function is available
[[WARNING]] The mb_strlen() function is available: FAILED
            *** Install and enable the mbstring extension ***
  OK        The iconv() function is available
  OK        The utf8_decode() is available
[[WARNING]] The posix_isatty() is available: FAILED
            *** Install and enable the php_posix extension (used to colorized the CLI output) ***
[[WARNING]] A PHP accelerator is installed: FAILED
            *** Install a PHP accelerator like APC (highly recommended) ***
  OK        php.ini has short_open_tag set to off
  OK        php.ini has magic_quotes_gpc set to off
  OK        php.ini has register_globals set to off
  OK        php.ini has session.auto_start set to off
  OK        PHP version is not 5.2.9
[iyunv@DBSVR01 e]#
  PDO扩展为PHP访问数据库定义了一个轻量级的、一致性的接口,它提供了一个数据访问抽象层,这样,无论使用什么数据库,都可以通过一致的函数执行查询和获取数据。PDO随PHP5.1发行,在PHP5.0的PECL扩展中也可以使用。
并不能使用PDO扩展本身执行任何数据库操作,必须使用一个database-specific PDO driver(针对特定数据库的PDO驱动)访问数据库服务器。

  PDO并不提供数据库抽象,它并不会重写SQL或提供数据库本身缺失的功能,如果你需要这种功能,你需要使用一个更加成熟的抽象层。
  PDO需要PHP5核心OO特性的支持,所以它无法运行于之前的PHP版本。
  在Unix环境下PHP5.1以上版本中:
  如果你正在使用PHP5.1版本,PDO和PDO SQLITE已经包含在了此发行版中;当你运行configure时它将自动启用。
  推荐你将PDO作为共享扩展构建,这样可以使你获得通过PECL升级的好处。
  推荐的构建支持PDO的PHP的configure line应该也要启用zlib。你也应该启用你选择的数据库的PDO驱动 ;
  关于这个的更多信息请查看database-specific PDO drivers ,但要注意如果你将PDO作为一个共享扩展构建,你必须也要将PDO驱动构建为共享扩展。
  SQLite扩展依赖于PDO,所以如果PDO作为共享扩展构建,SQLite也应当这样构建
  
  [iyunv@DBSVR01 e]# updatedb
[iyunv@DBSVR01 e]# locate php.ini
/etc/php.ini
/usr/share/doc/php-common-5.3.3/php.ini-development
/usr/share/doc/php-common-5.3.3/php.ini-production
[iyunv@DBSVR01 e]#
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-104775-1-1.html 上篇帖子: C语言开发php扩展链接库初学 下篇帖子: PHP函数处理函数实例详解
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表