11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 31 • INTRODUCING PDOwww.it-ebooks.infoInstalling PDOPDO is enabled by default as of version <strong>PHP</strong> 5.1; however, the <strong>MySQL</strong> PDO driver is not. Although it’spossible to install PDO and the desired PDO drivers as shared modules, the easiest approach is to buildPDO and the drivers statically; once complete, you won’t have to make any additional configurationrelatedchanges. Because you’re probably only currently interested in <strong>MySQL</strong>’s PDO driver, all you’llneed to do is pass the --with-pdo-mysql flag when configuring <strong>PHP</strong>.If you’re using <strong>PHP</strong> 5.1 or newer on the Windows platform, you need to add references to the PDOand driver extensions within the php.ini file. For example, to enable support for <strong>MySQL</strong>, add thefollowing lines to the Windows Extensions section:extension=php_pdo.dllextension=php_pdo_mysql.dllAs always, don’t forget to restart Apache in order for the php.ini changes to take effect.PDO’s Database OptionsAs of the time of this writing, PDO supports quite a few databases, in addition to any database accessiblevia DBLIB and ODBC, including:• 4D: Accessible via the PDO_4D driver.• Firebird / InterBase 6: Accessible via the PDO_FIREBIRD driver.• IBM DB2: Accessible via the PDO_IBM driver.• Informix: Accessible via the PDO_INFORMIX driver.• Microsoft SQL Server: Accessible via the PDO_DBLIB driver.• <strong>MySQL</strong>: Accessible via the PDO_MYSQL driver.• ODBC: Accessible via the PDO_ODBC driver. ODBC is not a database per se but itenables PDO to be used in conjunction with any ODBC-compatible databasenot found in this list.• Oracle: Accessible via the PDO_OCI driver. Oracle versions 8 through 11g aresupported.• PostgreSQL: Accessible via the PDO_PGSQL driver.• SQLite 3.X: Accessible via the PDO_SQLITE driver.■ Tip You can determine which PDO drivers are available to your environment either by loading phpinfo() intothe browser and reviewing the list provided under the PDO section header, or by executing the pdo_drivers()function like so:610

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!