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

SQL Anywhere 11.0.0 » SQL Anywhere Server - Programming » SQL Anywhere Data Access APIs » SQL Anywhere PHP API » Installing and configuring SQL Anywhere PHP

 

Configuring the SQL Anywhere PHP module

The behavior of the SQL Anywhere PHP driver can be controlled by setting values in the PHP initialization file, php.ini. The following entries are supported:

  • extension   Causes PHP to load the SQL Anywhere PHP module automatically each time PHP starts. Adding this entry to your PHP initialization file is optional, but if you don't add it, each script you write must start with a few lines of code that ensure that this module is loaded. The following entry is used for Windows platforms.
    extension=php-5.x.y_sqlanywhere.dll

    On Linux platforms, use one of the following entries. The second entry is thread safe.

    extension=php-5.x.y_sqlanywhere.so
    extension=php-5.x.y_sqlanywhere_r.so

    In these entries, 5.x.y identifies the PHP version.

    If the SQL Anywhere module is not always automatically loaded when PHP starts, you must prefix each script you write with the following lines of code. This code ensures that the SQL Anywhere PHP module is loaded.

    # Ensure that the SQL Anywhere PHP module is loaded
    if( !extension_loaded('sqlanywhere') ) {
        # Find out which version of PHP is running
        $version = phpversion();
        $module_name = 'php-'.$version.'_sqlanywhere';
        if( strtoupper(substr(PHP_OS, 0, 3) == 'WIN' )) {
            $module_ext = '.dll';
        } else {
            $module_ext = '.so';
        }
        dl( $module_name.$module_ext );
    }

  • allow_persistent   Allows persistent connections when set to 1. It does not allow them when set to 0. The default value is 1.
    sqlanywhere.allow_persistent=1

  • max_persistent   Sets the maximum number of persistent connections. The default value is -1, which means no limit.
    sqlanywhere.max_persistent=-1

  • max_connections   Sets the maximum number of connections that can be opened at once through the SQL Anywhere PHP module. The default value is -1, which means no limit.
    sqlanywhere.max_connections=-1

  • auto_commit   Specifies whether the database server performs a commit operation automatically. The commit is performed immediately following the execution of each statement when set to 1. When set to 0, transactions should be ended manually with either the sasql_commit or sasql_rollback functions, as appropriate. The default value is 1.
    sqlanywhere.auto_commit=1

  • row_counts   Returns the exact number of rows affected by an operation when set to 1 or an estimate when set to 0. The default value is 0.
    sqlanywhere.row_counts=0

  • verbose_errors   Returns verbose errors and warnings when set to 1. Otherwise, you must call the sasql_error or sasql_errorcode functions to get further error information. The default value is 1.
    sqlanywhere.verbose_errors=1

For more information, see sasql_set_option.