Learn how to install and use PHPPDO in PHP

Source: Internet
Author: User
Learn how to install and use PHPPDO. With the rapid development of PHP, its functions become more and more powerful. PDO (PHPDataObject) is a new feature of PHP5. when PHP6 is coming out, PHP6 only uses PDO by default to process databases. With the rapid development of PHP, its functions become more and more powerful. PDO (PHP Data Object) is a new feature of PHP 5, when PHP 6 comes out, PHP 6 only uses PDO by default to process the database, and all the database extensions are moved to PECL, by default, the php_mysql.dll and the like are lost. So what should we do? we have to keep up with the times, so I tried PDO. (This article is only an entry level. you can skip it)

What is php pdo?

PDO is a major new feature of PHP 5, because php4/php3 before PHP 5 was a bunch of database extensions to connect to and process various databases, php_mysql.dll, php_pgsql.dll, php_mssql.dll, php_sqlite.dll, and other extensions to connect to MySQL, PostgreSQL, ms SQL Server, and SQLite. Similarly, we must use ADOdb, PEAR: DB, PHPlib :: database abstract classes such as DB are very cumbersome and inefficient to help us. after all, how can we directly use C/C ++ to write php code with a high scaling slope? Therefore, the emergence of PDO is inevitable. you should accept it with a calm learning attitude. maybe you will find it can reduce your efforts.

Install PHP PDO

I am on Windows XP SP2, so the whole process is performed on Windows. for Linux/FreeBSD and other platforms, please find the information to set and install.
My PHP version is 5.1.4 and I already have the php_pdo.dll extension, but I need to set it up a little before it can be used.

Open c: windowsphp. ini, which is my PHP configuration file. find the following line:

 
 
  1. extension_dir

This is the directory of our extension. my PHP 5 extension is in: C: php5ext, so I will change this line:

 
 
  1. extension_dir = "C:/php5/ext"

Then find the following link under php. ini:

 
 
  1. Dynamic Extensions ;


Below are a bunch of things similar to extension = php_mbstring.dll. here is the PHP extension loading configuration. we will add our PDO extension at the end:

 
 
  1. extension=php_pdo.dll
  2. extension=php_pdo_mysql.dll
  3. extension=php_pdo_pgsql.dll
  4. extension=php_pdo_sqlite.dll
  5. extension=php_pdo_mssql.dll
  6. extension=php_pdo_odbc.dll
  7. extension=php_pdo_firebird.dll
  8. ;extension=php_pdo_oci8.dll

All the drivers of various php pdo can be added. However, the php_pdo_oci8.dll in the later part is not installed. if this is not the case, comment out it with a semicolon. Then restart our Web server, IIS/Apache, and I use IIS. hey, the table despise me. it's easy on Windows.

After the restart, write a phpinfo. php file under the document directory of our Web server, and add the following:

 
 
  1. <?
  2. phpinfo();
  3. ?>

Then open our lovely browser: IE/FireFox. I use FireFox 2.0. I just downloaded it. it's so nice. I'm not afraid of rogue software. haha. Enter http: // localhost/phpinfo. php in the browser. if the path on the page is inconsistent, enter the path on your own. In the output content, if you can see smoothly:

 
 
  1. PDO
  2. PDO support enabled
  3. PDO drivers mysql, pgsql, sqlite, mssql, odbc, firebird

The following describes various drivers: PDO_Firebird, pdo_mssql, pdo_mysql, PDO_ODBC, pdo_pgsql, and pdo_sqlite. congratulations, the installation is successful. otherwise, check the preceding steps carefully.


Parse (PHP Data Object) is a new feature of PHP 5. When PHP 6 is ready, PHP 6 uses PDO to process databases by default...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.