Configuring the SQL Anywhere PHP extension

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 extension 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 extension 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 extension 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 extension is loaded.



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

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

  • 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 extension. 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 On. When set to Off, transactions should be ended manually with either the sasql_commit or sasql_rollback functions, as appropriate. The default value is On.
    sqlanywhere.auto_commit=On

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

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

For more information, see sasql_set_option.