Setting Up Database Support in PHP


Adding database support to PHP can be a little involved, and how you do it depends on your operating system. We'll take a look at the most common choices here.

In Unix, Linux, and the Mac, you specify support for your database server during installation with configuration options, as detailed in the PHP installation directions. You'll find the directions for your specific database server in the server's PHP manual at www.php.net/dbname. For example, by using the --with-mysql[=DIR] configuration option, you enable PHP to access MySQL 4.0 databases, where DIR is the directory in which MySQL is installed, and it's set to /usr/local/mysql by default. For MySQL 4.1 databases (version 4.1 is being tested as of this writing and is not recommended for general use), use --with-mysql[=DIR]. In this case, DIR has no default value and should be set to the path to the file mysql_config, which is part of the MySQL 4.1 installation. For Oracle, you use the configuration option --with-oci8[=DIR], where DIR defaults to your environment variable ORACLE_HOME. PHP installations on ISPs are usually already configured for MySQL and other database servers as well; ask your ISP's tech support for the details.

In Windows, you'll find a dynamic link library (DLL) for every supported database server in PHP's ext directory (depending on your PHP installation, that could be, for example, c:\php\ext). Find the correct DLL for the database server you want in that directory and copy it to the main directory (such as c:\php). For example, for MySQL version 4.0 or earlier, this file is php_mysql.dll; for MySQL version 4.1 or later, it's php_mysqli.dll; for Oracle, it's php_oci8.dll; for Microsoft's SQL Server, it's mssql.dll; and so on. After copying the DLL file, you activate the support for the database server by uncommenting its "extension=" line in php.ini by removing the semi-colon at the start of the line. For example, here's how you'd activate support for MySQL version 4.0 in php.ini:

 ;extension=php_mime_magic.dll ;extension=php_mssql.dll ;extension=php_msql.dll extension=php_mysql.dll ;extension=php_oci8.dll ;extension=php_openssl.dll ;extension=php_oracle.dll ;extension=php_pdf.dll ;extension=php_pgsql.dll         .         .         . 

After making these configuration changes in Windows, restart PHP.



    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net