zoukankan      html  css  js  c++  java
  • PHPPDO

    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

    1. 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.

    2. 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

    [root@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
    [root@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.
    [root@DBSVR01 e]#

    [root@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!
    [root@DBSVR01 e]#

    [root@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
    [root@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也应当这样构建

    [root@DBSVR01 e]# updatedb
    [root@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
    [root@DBSVR01 e]#

  • 相关阅读:
    ios NSFileHandle
    ios NSString crash
    触摸方法
    代理中方法
    初始化时加载的方法
    [leetCode]209. 长度最小的子数组
    [leetCode]669. 修剪二叉搜索树
    [leetCode]763. 划分字母区间
    7.Jedis
    6.Redis事务(乐观锁)
  • 原文地址:https://www.cnblogs.com/simhare/p/3052720.html
Copyright © 2011-2022 走看看