Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere PHP API » Installing and configuring SQL Anywhere PHP

Installing the PHP module on Windows Next Page

Installing the PHP module on Linux


To use the SQL Anywhere PHP module on Linux, you must copy the shared object from the SQL Anywhere installation directory and add it to your PHP installation. Optionally, you can add an entry to your PHP initialization file, php.ini, to load the module, so you do not need to load it manually in each script.

To install the PHP module on Linux
  1. Locate the php.ini file of your PHP installation, and open it in a text editor. Locate the line that specifies the location of the extension_dir directory.

  2. Copy the shared object from the lib subdirectory of your SQL Anywhere installation to the directory specified by the extension_dir entry in the php.ini file.

    Note

    If your version of PHP is more recent than the shared object provided by SQL Anywhere, try using the most recent shared object provided. For example, if you installed PHP 5.1.6, and the most recent shared object is php-5.1.2_sqlanywhere10_r.so, use php-5.1.2_sqlanywhere10_r.so.

    For information on which version of the shared object to use, see Choosing which PHP module to use.

  3. Optionally, add the following line to the php.ini file to load the SQL Anywhere PHP driver automatically. Alternatively, you can load it manually with a few extra lines of code at the start of each script that requires it. The entry must identify the shared object you copied, which is either

    extension=phpX_sqlanywhere10.so

    or, for the thread-safe shared object,

    extension=phpX_sqlanywhere10_r.so

    where X is the version number of the PHP shared object copied in the previous step.

  4. Before attempting to use the PHP module, verify that your environment is set up for SQL Anywhere. Depending on which shell you are using, enter the appropriate command to source the SQL Anywhere configuration script from the SQL Anywhere installation directory:

    In this shell ... ... use this command
    sh, ksh, or bash . /bin32/sa_config.sh
    csh or tcsh source /bin32/sa_config.csh
  5. At a command prompt, enter the following command to start the SQL Anywhere sample database:

    dbeng10 demo.db

    You may have to specify the location of the SQL Anywhere sample database on the command line.

  6. At a command prompt, change to the src/php/examples subdirectory of your SQL Anywhere installation. Enter the following command:

    php connect.php

    The message Connected successfully should appear. If the php command is not recognized, verify that it is in your path.

  7. When you are done, stop the database server by pressing Q in the console window where it is running.

For more information, see Creating PHP test pages.