0% found this document useful (0 votes)
6 views

Adaptive Server Enterprise Programmers Guide For PHP en

Uploaded by

arifegcb.ict
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Adaptive Server Enterprise Programmers Guide For PHP en

Uploaded by

arifegcb.ict
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

PUBLIC

SDK for SAP Adaptive Server Enterprise 16.0 SP03


Document Version: 1.0 – 2020-03-04

Programmers Guide for PHP


© 2020 SAP SE or an SAP affiliate company. All rights reserved.

THE BEST RUN


Content

1 Adaptive Server Enterprise Extension Module for PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4


1.1 Installing the Extension Module for PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Configuration Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Sample PHP Scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Support for DSN-style Connection Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Valid Attribute Names and Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Extension Module for PHP API Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
sybase_affected_rows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
sybase_close. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
sybase_connect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
sybase_data_seek. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
sybase_fetch_array. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
sybase_fetch_assoc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
sybase_fetch_field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
sybase_fetch_object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
sybase_fetch_row. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
sybase_field_seek. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
sybase_free_result. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
sybase_get_last_message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
sybase_get_last_status. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
sybase_next_result. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sybase_num_fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sybase_num_rows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
sybase_pconnect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
sybase_query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
sybase_rpc_bind_param_ex. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
sybase_rpc_execute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
sybase_rpc_init. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
sybase_select_db. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
sybase_set_message_handler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
sybase_unbuffered_query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
sybase_use_result. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.5 Security and Directory Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
1.6 Additional Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2 Multiversion Concurrency Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30


2.1 Connection Support in Multiversion Concurrency Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30

Programmers Guide for PHP


2 PUBLIC Content
2.2 Scripting Drivers Support in Multiversion Concurrency Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3 Glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Programmers Guide for PHP


Content PUBLIC 3
1 Adaptive Server Enterprise Extension
Module for PHP

The SAP Adaptive Server Enterprise extension module for the PHP scripting language allows PHP developers
to execute queries against an SAP ASE database.

The extension module for PHP is a vendor-specific database interface driver that executes queries against an
SAP ASE database. The open source programming language, PHP (Hypertext Preprocessor) provides the
ability to retrieve information from common databases. The SAP ASE extension module for the PHP scripting
language includes the necessary PHP APIs to enable PHP developers to write standalone scripts to execute
queries against an SAP ASE database.

The extension module for PHP has been tested against the command line PHP implementation. Usage of the
extension, such as a CGI module in a Web server, is beyond the scope of SAP testing.

Required Components

Access to an SAP ASE database using the PHP programming language requires the following components:

● PHP script – application script to connect to an SAP ASE database server.


● SAP ASE extension module for PHP – is the vendor-specific driver supported by SAP. The extension is
called through the PHP script and connects to the API layer DBCAPI.
● DBCAPI – is a function library that acts as intermediate conversion layer between the PHP extension and
the CT-Library.
● CT-Library – is a SAP Open Client library that you can use to send commands to SAP ASE server, process
the results and return the data.

Version Requirements

For information about platform support, see the Software Developers Kit and Open Server Installation Guide for
your platform.

● SAP ASE – version 15.7 or later. The PHP driver has been developed and tested against version 15.7 and
16.0. However, the driver can connect to SAP ASE version earlier than 15.7.
● PHP installation – version 5.3.6 or 5.6.5.
● CT-Library from Open Client SDK – version 15.7
● DBCAPI — SAP recommends that you use the DBCAPI library and the PHP driver from the same SDK
installation.

Programmers Guide for PHP


4 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Related Information

Installing the Extension Module for PHP [page 5]


Sample PHP Scripts [page 6]
Support for DSN-style Connection Properties [page 7]
Extension Module for PHP API Reference [page 10]
Security and Directory Services [page 29]
Additional Resources [page 29]

1.1 Installing the Extension Module for PHP

The extension module for PHP is a component you can install through the Sybase Installer.

The extension module for PHP is an optional installation component when you choose Custom as the
installation type. The extension is installed by default if the installation type you choose is Typical or Full.

This is an overview of the extension module installation; for complete installation instructions, see the SAP
Open Server and SDK for SAP ASE Installation Guide for your platform.

● Pre-installation requirements:
○ PHP installation 5.3.6 or 5.6.5 – 64-bit only.
○ Open Client SDK is required. The DBCAPI library is included in the Open Client SDK and is installed
together with the core Open Client (CT-Library).
Do not install DBCAPI as part of the driver.
● The extension module for PHP is installed as a PHP extension in a dynamic library.
The Sybase installer installs the extension module into the Open Client (CT-Library) directory as one
shared library called sybaseasephp.so.
● These files are installed with the extension module:
$SYBASE/$SYBASE_OCS/php/php<version>_64/lib/sybaseasephp.so
$SYBASE/$SYBASE_OCS/php/php<version>_64/devlib/sybaseasephp.so
$SYBASE/$SYBASE_OCS/sample/php/README
$SYBASE/$SYBASE_OCS/sample/php/firstapp.php
$SYBASE/$SYBASE_OCS/sample/php/dsnconnect.php

Related Information

Configuration Overview [page 6]

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 5
1.1.1 Configuration Overview

Configure your environment to locate the extension module and OCS installations.

Environment Variables

To successfully use the extension module, set Sybase environment variables in the environment in which you
run the PHP executable. At a minimum, you must set the $SYBASE and $SYBASE_OCS environment variables.
Set the <LD_LIBRARY_PATH> variable to point to the correct location under the $SYBASE/$SYBASE_OCS/lib
directory. The extension module loads the DBCAPI library from this location.

PHP Configuration

A system administrator can copy the extension module into a different extension specific directory and load
the extension module from the directory by modifying the php.ini file, for example:

; Set the default extension directory.


extension_dir = "/usr/local/lib/php/extensions"
;Load the Sybase ASE PHP driver: sybaseasephp extension="sybaseasephp.so"

Once the file is modified, you can copy the $SYBASE/$SYBASE_OCS/php/php536_64/lib/


sybaseasephp.so or $SYBASE/$SYBASE_OCS/php/php536_64/devlib/sybaseasephp.so library
to /usr/local/lib/php/extensions.

Extension Libraries

When executing php -m you should see the sybaseasephp extension listed among the extensions active in
the PHP installation.

 Note

You need not place all extension libraries of a particular PHP installation in the same directory.

1.2 Sample PHP Scripts

Sample PHP scripts are installed in $SYBASE/$SYBASE_OCS/sample/php/

For information about running the sample scripts, see the README file located in the same directory. Also see
the Software Developers Kit and Open Server Installation Guide for platform installation information.

Programmers Guide for PHP


6 PUBLIC Adaptive Server Enterprise Extension Module for PHP
The PHP sample scripts are:

● firstapp.php – a simple example program that connects to a server, sends a select query, and prints the
rows.
● dsnconnect.php – a simple example program that connects to a server using a DSN connection string. It
optionally prints out the servername, account, and the current database.

1.3 Support for DSN-style Connection Properties

sybase_connect() and sybase_pconnect() APIs support DSN-style connection properties.

When you call either sybase_connect() or sybase_pconnect() APIs using only the servername
parameter, servername must contain a valid DSN (data source name) string. The data source name is a
semicolon (;) separated string of name=value parts as explained as follows:

1. Name – a case-insensitive value that can be delimited by an equal sign (=) or semicolon (;). An attribute
can have multiple synonyms. For example, server and servername refer to the same attribute.
2. Equals sign (=) – indicates the start of the value to be assigned to the Name. If there is no equals sign, the
Name is assumed to be of boolean type with a value of true.
3. Value – a string that is terminated by a semicolon (;). Use a backslash (\) if a semicolon or another back
slash is present in the value. Values can be of type boolean, integer, or string. Valid values for Boolean types
are true, false, on, off, 1, and 0.

 Note

If a boolean name is present without a value, the Boolean type must be set to true.

For example:

Username=name;Password=pwd;Timeout=10

Related Information

Valid Attribute Names and Values [page 8]

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 7
1.3.1 Valid Attribute Names and Values

The table lists the valid attribute names and values for the dsn keyword argument.

Name Description Value

ANSINull Determines whether evaluation of NULL-valued operands in Boolean value.


SQL equality (=) or inequality (!=) comparisons is ANSI-com­
The default is false.
pliant.

If the value is true, SAP Adaptive Server Enterprise enforces


the ANSI behavior that <= NULL> and <is NULL> are not
equivalent. In standard Transact-SQL, <= NULL> and <is
NULL> are considered to be equivalent.

This option affects <> NULL> and <is not NULL> behavior in
a similar fashion.

BulkLogin Determines whether a connection is enabled to perform a bulk- Boolean value.


copy operation.
The default is false.

ChainXacts If true, SAP ASE uses chained transaction behavior, that is, Boolean value.
each server command is considered to be a distinct transac­
The default is false.
tion.

SAP ASE implicitly executes a begin transaction before any of


these statements: delete, fetch, insert, open,
select, and update. You must still explicitly end or roll back
the transaction.

If false, an application must specify explicit begin transaction


statements paired with commit or rollback statements.

Charset Specifies the charset to be used on this connection. String value.

Confidentiality Whether data encryption service is performed on the connec­ Boolean value.
tion.
The default is false.

CredentialDelegation Determines whether to allow the server to connect to a second Boolean value.
server with the user’s delegated credentials.
The default is false.

DetectReplay Determines whether the connection’s security mechanism de­ Boolean value.
tects replayed transmissions.
The default is false.

DetectOutOfSequence Determines whether the connection’s security mechanism de­ Boolean value.
tects transmissions that arrive out of sequence.
The default is false.

Programmers Guide for PHP


8 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Name Description Value

Integrity Determines whether the connection’s security mechanism per­ Boolean value.
forms data integrity checking.
The default is false.

Interfaces The path and name of the interfaces file. String value.

Keytab The name and path to the file from which a connection’s secur­ String value.
ity mechanism reads the security key to go with the
The default is NULL,
<username> value.
that is, the user must
have established cre­
dentials before con­
necting.

Locale Determines which language and character set to use for mes­ String value.
sages, datatype conversions, and datetime formats.

Language Determines which language set to use for messages, datatype String value.
conversions, and datetime formats.

LoginTimeout Specifies the login timeout value. Integer value.

MaxConnect Specifies the maximum number of simultaneously open con­ Integer value.
nections that a context may have.
Default value is 25.
Negative and zero val­
ues are not allowed.

MutualAuthentication Determines whether the server is required to authenticate it­ Boolean value.
self to the client.
The default is false.

NetworkAuthentication Determines whether the connection’s security mechanism per­ Boolean value.
forms network-based user authentication.
The default is false.

PacketSize Specifies the TDS packet size. Integer value.

Password Specifies the password used to log in to the server. String value.

PasswordEncryption Determines whether the connection uses asymmetrical pass­ Boolean value.
word encryption.
The default is false.

SecurityMechanism Specifies the name of the network security mechanism that String value.
performs security services for the connection.
The default value de­
pends on security
driver configuration.

Server Specifies the name of the server to which you are connected. String value.

Servername

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 9
Name Description Value

ServerPrincipalName Specifies the network security principal name for the server to String value.
which a connection is opened.
The default is NULL,
which means that the
connection assumes
the server principal
name is the same as
its <ServerName>
value.

Keepalive Determines whether to use the KEEPALIVE option. Boolean value.

The default is true.

Timeout Specifies the connection timeout value. Integer value.

UID Specifies the name used to log in to the server. String value.

User

Username

dsnconnect.php Sample Program

The dsnconnect.php sample program connects to a server using a DSN connection string. It optionally prints
the server name, the user account, and the current database.

1.4 Extension Module for PHP API Reference

The extension module interface API.

Related Information

sybase_affected_rows [page 11]


sybase_close [page 12]
sybase_connect [page 12]
sybase_data_seek [page 13]
sybase_fetch_array [page 14]
sybase_fetch_assoc [page 15]
sybase_fetch_field [page 15]

Programmers Guide for PHP


10 PUBLIC Adaptive Server Enterprise Extension Module for PHP
sybase_fetch_object [page 16]
sybase_fetch_row [page 17]
sybase_field_seek [page 17]
sybase_free_result [page 18]
sybase_get_last_message [page 19]
sybase_get_last_status [page 19]
sybase_next_result [page 20]
sybase_num_fields [page 20]
sybase_num_rows [page 21]
sybase_pconnect [page 22]
sybase_query [page 23]
sybase_rpc_bind_param_ex [page 23]
sybase_rpc_execute [page 24]
sybase_rpc_init [page 25]
sybase_select_db [page 26]
sybase_set_message_handler [page 26]
sybase_unbuffered_query [page 27]
sybase_use_result [page 28]

1.4.1 sybase_affected_rows

Returns the number of rows affected by the last INSERT, UPDATE, or DELETE query on the connection referred
to by $conn.
This function is typically used for INSERT, UPDATE, or DELETE statements. For SELECT statements, use the
sybase_num_rows() function instead.

Syntax

int sybase_affected_rows([resource $conn])

Parameters

$conn
the connection resource returned by a connection opening function. If the connection
resource isn't specified, the most recently opened connection is used.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 11
Returns

The number of rows affected by the last INSERT, UPDATE, or DELETE query.

1.4.2 sybase_close

Closes a connection.

Syntax

bool sybase_close([resource $conn])

Parameters

$conn
the connection resource returned by a connection opening function. If the connection
resource is not specified, the most recently opened connection is closed.

Returns

TRUE on success.

FALSE on failure.

1.4.3 sybase_connect

Opens a connection to SAP Adaptive Server Enterprise.


sybase_connect() supports DSN style connection properties. When it is called with the parameter
<servername> only, <servername> is expected to contain a valid DSN string.

Syntax

resource sybase_connect([string $servername


[, string $username

Programmers Guide for PHP


12 PUBLIC Adaptive Server Enterprise Extension Module for PHP
[, string $password
]]] )

Parameters

$servername
when sybase_connect() is called with more than this parameter, then $servername
contains a server defined in the relevant Sybase directory service. When
sybase_connect() is called with only this parameter, then $servername contains a
valid DSN connection string of syntax: param1=val1;param2=val2;...

$username
the user account used to log in to SAP ASE server.
$password
the password of the user account with which to log in to SAP ASE server.

Returns

A positive connection identifier on success.

FALSE on failure.

1.4.4 sybase_data_seek

Moves the internal row pointer on the result set associated with the result identifier to point to the specified
row number.

Syntax

bool sybase_data_seek(resource $result, int $row)

Parameters

$result
the result resource that comes from a call to sybase_query().

$row

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 13
the row number (starting with 0) to set the internal pointer to.

Returns

TRUE – internal pointer has been successfully positioned.

FALSE – failed to set the internal pointer correctly.

1.4.5 sybase_fetch_array

Fetches a result row as an associative array, a numeric array, or both.

Syntax

mixed sybase_fetch_array(resource $result


[, int $result_type ] )

Parameters

$result
the result resource that comes from a call to sybase_query()..

$result_type
the type of array to be returned. It accepts the following values to return arrays with:

SYB_FETCH_ASSOC – associative array

SYB_FETCH_NUM – numeric array

SYB_FETCH_BOTH – (Default) both associative & number indices

Returns

Associative array (identical to sybase_fetch_assoc()) when $result_type is SYB_FETCH_ASSOC or


SYB_FETCH_BOTH.

Numeric array (identical to sybase_fetch_row()) when $result_type is SYB_FETCH_NUM or


SYB_FETCH_BOTH.

FALSE – there were no more rows to be fetched.

Programmers Guide for PHP


14 PUBLIC Adaptive Server Enterprise Extension Module for PHP
1.4.6 sybase_fetch_assoc

Fetches one row of data from the result set associated with the specified result identifier in an associative
array.
Positions the internal pointer one row farther in the result set. A subsequent call to sybase_fetch_assoc()
returns the next row in the result set, or FALSE if there are no more rows.

Syntax

array sybase_fetch_assoc(resource $result)

Parameters

$result
the result resource that comes from a call to sybase_query().

Returns

On success, returns the next row in the result set.

FALSE – there were no more rows to be fetched.

1.4.7 sybase_fetch_field

Returns an object containing field information.


This function can be used to obtain information about fields in the provided query result.

Syntax

object sybase_fetch_field(resource $result [, int $field_offset ])

Parameters

$result

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 15
the result resource that comes from a call to sybase_query().

$field_offset
the field number (starting from 0) to retrieve information from. If the field offset is not
specified, the next field that is not yet retrieved by this function is used.

Returns

Returns an object with the following field information as properties:

Field name Field type Field description

name string Column name.

table string The table from which the column was taken.

max_length int Maximum length of the column.

type string Data type of the column, as defined in cspublic.h.

1.4.8 sybase_fetch_object

Fetches a row as an object.


This function is similar to sybase_fetch_assoc(), but it returns an object rather than an array. It positions
the internal pointer one row farther in the result set.

Syntax

object sybase_fetch_object(resource $result [, mixed $object ])

Parameters

$result
the result resource that comes from a call to sybase_query().

$object
optionally, specify the type of object to be returned. The default object type is stdClass.

Returns

Returns an object with properties that correspond to the fetched row's field names.

Programmers Guide for PHP


16 PUBLIC Adaptive Server Enterprise Extension Module for PHP
FALSE – there were no more rows to be fetched.

1.4.9 sybase_fetch_row

Fetches one row of data from the result set associated with the specified result identifier in a numerical array.
It positions the internal pointer one row farther in the result set.

A subsequent call to sybase_fetch_row() returns the next row in the result set, or FALSE if there are no
more rows.

Syntax

array sybase_fetch_row(resource $result)

Parameters

$result
the result resource that comes from a call to sybase_query().

Returns

Numerical array (starting at 0) – identical to sybase_fetch_array($result, SYB_FETCH_NUM)

FALSE – there are no more rows to be fetched.

1.4.10 sybase_field_seek

Sets the internal pointer to the requested field offset.


If the next call to sybase_fetch_field() does not specify a field offset, the field internal pointer is set to,
can be used.

Syntax

bool sybase_field_seek(resource $result, int $field_offset)

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 17
Parameters

$result
the result resource that comes from a call to sybase_query().

$field_offset
the field offset (starting at 0).

Returns

TRUE – internal pointer set correctly.

FALSE – failed to set internal pointer correctly.

1.4.11 sybase_free_result

Frees all memory associated with this result set.

Although result memory is automatically freed when the PHP script ends. SAP recommends, as a good
programming practice, that you free memory that is no longer needed.

Syntax

bool sybase_free_result(resource $result)

Parameters

$result
the result resource that comes from a call to sybase_query().

Returns

TRUE – memory freed successfully.

FALSE – failed to free the memory.

Programmers Guide for PHP


18 PUBLIC Adaptive Server Enterprise Extension Module for PHP
1.4.12 sybase_get_last_message

The last message returned by the Server.

Syntax

string sybase_get_last_message(void)

Parameters

None

Returns

The last message returned by the server.

FALSE – failed to retrieve the last server message.

1.4.13 sybase_get_last_status

Returns the last status result that was sent on the connection $conn.

Syntax

int sybase_get_last_status(resource $conn)

Parameters

$conn
the connection resource returned by a connection opening function.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 19
Returns

The last status result that was sent on the connection $conn.

1.4.14 sybase_next_result

Returns a result set identifier pointing to the next result set on connection $conn.

Syntax

mixed sybase_next_result(resource $conn)

Parameters

$conn
the connection resource returned by a connection opening function.

Returns

A positive Sybase result set identifier on success.

FALSE – there is no further result set on the connection.

1.4.15 sybase_num_fields

Returns the number of fields in the result set.

Syntax

int sybase_num_fields(resource $result)

Programmers Guide for PHP


20 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Parameters

$result
the result resource that comes from a call to sybase_query().

Returns

The number of fields in the result set.

FALSE – failed to retrieve the number of fields.

1.4.16 sybase_num_rows

Returns the number of rows in the result set of a SELECT statement.


sybase_num_rows() returns the correct number of rows when the complete result set has been read.

Syntax

int sybase_num_rows(resource $result)

Parameters

$result
the result resource that comes from a call to sybase_query().

Returns

The number of rows in the result set.

FALSE – failed to retrieve the number of rows.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 21
1.4.17 sybase_pconnect

Opens a persistent connection to SAP Adaptive Server Enterprise.


sybase_pconnect() supports DSN style connection properties. When it is called with the parameter
<servername> only, <servername> is expected to contain a valid DSN string.

 Note

If a persistent connection has been previously opened with the same arguments as this call, an identifier
for the existing connection gets returned instead of opening a new connection.

Syntax

resource sybase_pconnect([string $servername


[, string $username
[, string $password
]]] )

Parameters

$servername
when sybase_connect() is called with more than this parameter, then $servername
contains a server defined in the relevant Sybase directory service. When
sybase_connect() is called with only this parameter, then $servername contains a
valid DSN connection string of syntax: param1=val1;param2=val2;...

$username
the name of the user account used to login to SAP ASE Server.
$password
the password of the user account used to login to SAP ASE Server.

Returns

A positive connection identifier on success.

FALSE – on failure.

Programmers Guide for PHP


22 PUBLIC Adaptive Server Enterprise Extension Module for PHP
1.4.18 sybase_query

Sends a query to the connection.

Syntax

mixed sybase_query(string $query [, resource $conn])

Parameters

$query
a string containing the query to be sent to the SAP ASE server.
$conn
the connection resource returned by a connection opening function. If the connection
resource is not specified, the most recently opened connection is used.

Returns

A positive Sybase result set identifier on success.

TRUE – query was successful, but no result set was returned.

FALSE – query failed.

1.4.19 sybase_rpc_bind_param_ex

Binds a PHP variable to a remote procedure parameter.

Syntax

bool sybase_rpc_bind_param_ex(resource $stmt,


int $param_id,
mixed $var,
string $type
[, bool $is_null
[, int $direction]] )

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 23
Parameters

$stmt
a statement identifier resource returned by a sybase_rpc_init() call.

$param_id
positional index of the stored procedure parameter to bind with. It starts with 0 for the
first parameter.
$var
reference to (address of) the PHP variable to be bound.
$type
the data type of the PHP variable that will be bound. One of: 'd' - double

'i' - integer

'b' - binary

's' - string
$is_null
an optional boolean indicating whether the variable contains a NULL or not.
$direction
optionally, one of: SASE_D_INPUT – for an input parameter (default).

SASE_D_OUTPUT – for an output parameter.

Returns

TRUE – binding the PHP variable succeeded.

FALSE – binding the PHP variable failed

1.4.20 sybase_rpc_execute

Executes the remote procedure call that was initialized with sybase_rpc_init() in $stmt.

Syntax

mixed sybase_rpc_execute(resource $stmt)

Programmers Guide for PHP


24 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Parameters

$stmt
a statement identifier resource returned by a sybase_rpc_init() call.

Returns

A positive Sybase result set identifier on success.

FALSE – the RPC execution failed.

1.4.21 sybase_rpc_init

Returns a statement identifier pointing to the statement initialized for $procedure on connection $conn.

Syntax

mixed sybase_rpc_init(resource $conn, string $procedure)

Parameters

$conn
the connection resource returned by a connection opening function.
$procedure
the name of the remote (stored) procedure to be executed with
sybase_rpc_execute().

Returns

A positive Sybase statement identifier on success.

FALSE – initialization of the RPC statement failed.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 25
1.4.22 sybase_select_db

Sets the current active database on the server referred to by the connection resource.
Every subsequent call to sybase_query() is made on the active database of the current connection resource.

Syntax

bool sybase_select_db(string $database_name [, resource $conn])

Parameters

$database_name
the name of the database to use.
$conn
the connection resource returned by a connection opening function.
If the connection resource is
not specified, the most recently opened connection is used.

Returns

TRUE – current database set successfully.

FALSE – failed to set current database.

1.4.23 sybase_set_message_handler

Sets a user defined callback function that is called when either a client or a server message is received.

Syntax

bool sybase_set_message_handler(callback $handler, int $msg_type


[, resource $conn])

Programmers Guide for PHP


26 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Parameters

$handler
the callback handler takes the following arguments:

int – message_number

int – severity

int – state

int – line_number

string – description
$msg_type
one of:

SYB_CLIENTMSG_CB – a client message callback

SYB_SERVERMSG_CB – a server message callback

 Note

Although $msg_type is mandatory, currently it is ignored as the installed message


handler is called for both client and server messages.

$conn
the connection resource returned by a connection opening function.
If the connection resource is
not specified, the most recently opened connection is used.

Returns

TRUE – callback function installed successfully.

FALSE – failed to install callback function.

1.4.24 sybase_unbuffered_query

Sends a query to the connection referred to by $conn.


The complete result set is not automatically fetched and buffered as with sybase_query(). This yields better
performance, especially with large result sets.

Use sybase_fetch_array() and similar functions to read more rows as needed and use
sybase_data_seek() to jump to the target row.

Use sybase_num_rows() to return the correct number of rows when the complete result set has been read.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 27
Syntax

mixed sybase_unbuffered_query(string $query [, resource $conn])

Parameters

$query
a string containing the query to be sent to SAP ASE server.
$conn
the connection resource returned by a connection opening function.

If the connection resource is not specified, the most recently opened connection is
used.

Returns

A positive Sybase result set identifier on success.

TRUE – query has been successful but no result set was returned.

FALSE – query failed.

1.4.25 sybase_use_result

Stores the result set of the last unbuffered query on connection $conn and returns a result set identifier
pointing to this stored result set.

Syntax

mixed sybase_use_result(resource $conn)

Parameters

$conn
the connection resource returned by a connection opening function.

Programmers Guide for PHP


28 PUBLIC Adaptive Server Enterprise Extension Module for PHP
Returns

A positive Sybase result set identifier on success.

FALSE – there is no further result set on the connection to store.

1.5 Security and Directory Services

Configure security options using the ocs.cfg and libtcl.cfg files.

The extension module options enabling security are currently not supported.

For a connection, use ocs.cfg to set directory and security properties. Edit libtcl.cfg to load security and
directory service drivers.

For more information, see Configuration Files in the Open Client and Open Server Configuration Guide for UNIX.

1.6 Additional Resources

Additional information for installing and configuring the extension module.

● Open Client and Open Server documentation for configuration information:


Open Client and Open Server Configuration Guide for UNIX > Configuration Files
● Platform related issues for all the Open Client and Open Server products:
Open Client and Open Server Programmers Supplement for UNIX
● Using the Open Client and Open Server runtime configuration file:
Open Client Client-Library/C Reference Manual > Using the runtime configuration file > Open Client and
Open Server runtime configuration file syntax
● Platform support:
Software Developer Kit and Open Server Installation Guide for your platform.

Programmers Guide for PHP


Adaptive Server Enterprise Extension Module for PHP PUBLIC 29
2 Multiversion Concurrency Control

Multiversion concurrency control (MVCC) enables concurrent read-write operations, by allowing the server to
lock rows for writing in one session while granting access to unaltered versions of these rows in another
session, so that reads never wait for writes, and writes never wait for reads.

SAP ASE offers two types of MVCC:

● Regular MVCC – uses in-memory row versioning, where all inserts, updates, and deletes are performed in
the in-memory row storage.
● On-disk multiversion concurrency control (on-disk MVCC) – stores row versions in a temporary database
specified when the database is created or altered.

The two types use slightly different parameters to create or alter the database. In addition to the standard
isolation levels offered by SAP ASE, SAP ASE uses three isolation levels specifically to enable multiversion
concurrency control, which are not part of the standard SQL:

● Statement snapshot
● Transaction snapshot
● Readonly statement snapshot

Related Information

Connection Support in Multiversion Concurrency Control [page 30]


Scripting Drivers Support in Multiversion Concurrency Control [page 32]

2.1 Connection Support in Multiversion Concurrency


Control

ISOLATION_MODE is a connection-level property that is used to enable the MVCC feature by converting ANSI
isolation levels to snapshot isolation levels for MVCC- and on-disk MVCC-enabled tables.

 Note

SAP ASE provides the following techniques to migrate applications to use snapshot isolation seamlessly,
and with minimal application changes. Perform these changes on the application in conjunction with any
necessary server-side changes. If you do not set the ISOLATION_MODE property, existing applications
default to run at ANSI isolation levels.

You can set the ISOLATION_MODE connection property for the client and map ANSI isolation levels to snapshot
isolation levels. When ISOLATION_MODE is set to snapshot, the isolation level maps as:

Programmers Guide for PHP


30 PUBLIC Multiversion Concurrency Control
● Isolation level 0 and 1 ‒ mapping to the statement snapshot isolation level
● Isolation level 2 and 3 ‒ mapping to the transaction snapshot isolation level

Once the ISOLATION_MODE connection property is set, the server overrides the set transaction
isolation command from the connection or system procedure, which avoids having to make application
changes to set isolation levels. For example, if a stored procedure sets the isolation level to ANSI isolation levels
0, 1, 2, or 3, but when using MVCC-enabled tables and the ISOLATION_MODE property is set, the ANSI isolation
level for the stored procedure is converted to the statement snapshot or transaction snapshot
isolation levels described above.

ISOLATION_MODE can have these values:

● default – the applications use the isolation levels specified by the application.
● snapshot – the application uses the snapshot isolation levels listed in the following table when it specifies
traditional ANSI isolation levels for MVCC-enabled tables.
● readonly_snapshot – the application uses the snapshot isolation levels listed in the following table when
it specifies traditional ANSI isolation levels for MVCC-enabled tables.

Connection Isolation Mode


Connection Isolation Mode Connection Isolation Mode set to READONLY_SNAP­
Session-level Isolation Level set to DEFAULT set to SNAPSHOT SHOT

read uncommitted read uncommitted statement snapshot readonly statement


snapshot

read commited read commited statement snapshot readonly statement


snapshot

repeatable read repeatable read transaction transaction


snapshot snapshot

serializable read serializable read transaction transaction


snapshot snapshot

statement snapshot statement snapshot statement snapshot statement snapshot

transaction transaction transaction transaction


snapshot snapshot snapshot snapshot

readonly statement readonly statement readonly statement readonly statement


snapshot snapshot snapshot snapshot

Programmers Guide for PHP


Multiversion Concurrency Control PUBLIC 31
2.2 Scripting Drivers Support in Multiversion Concurrency
Control

The IsolationMode= connection string property is supported for the scripting drivers and maps to the
CS_OPT_ISOLATION_MODE option. Valid values for this property are 0, 1, and 2.

Programmers Guide for PHP


32 PUBLIC Multiversion Concurrency Control
3 Glossary

Glossary of term specific to scripting languages.

Client-Library part of Open Client, a collection of routines for use in writing client applications. Client-Library
is designed to accommodate cursors and other advanced features in the Sybase product line.

CS-Library included with both the Open Client and Open Server products, a collection of utility routines
that are useful to both Client-Library and Server-Library applications.

CT-Library (CT-Lib API) is part of the Open Client suite and is required to let an scripting application
connect to Adaptive Server.

PHP self-referential acronym for Hypertext Preprocessor.

thread a path of execution through Open Server application and library code and the path’s
associated stack space, state information, and event handlers.

Transact-SQL an enhanced version of the database language SQL. Applications can use Transact-SQL to
communicate with Adaptive Server Enterprise.

Programmers Guide for PHP


Glossary PUBLIC 33
Important Disclaimers and Legal Information

Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information.
About the icons:

● Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your
agreements with SAP) to this:

● The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.
● SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any
damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.

● Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering a SAP-hosted Web site. By using such
links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this
information.

Beta and Other Experimental Features


Experimental features are not part of the officially delivered scope that SAP guarantees for future releases. This means that experimental features may be changed by
SAP at any time for any reason without notice. Experimental features are not for productive use. You may not demonstrate, test, examine, evaluate or otherwise use
the experimental features in a live operating environment or with data that has not been sufficiently backed up.
The purpose of experimental features is to get feedback early on, allowing customers and partners to influence the future product accordingly. By providing your
feedback (e.g. in the SAP Community), you accept that intellectual property rights of the contributions or derivative works shall remain the exclusive property of SAP.

Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax
and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of
example code unless damages have been caused by SAP's gross negligence or willful misconduct.

Gender-Related Language
We try not to use gender-specific word forms and formulations. As appropriate for context and readability, SAP may use masculine word forms to refer to all genders.

Videos Hosted on External Platforms


Some videos may point to third-party video hosting platforms. SAP cannot guarantee the future availability of videos stored on these platforms. Furthermore, any
advertisements or other content hosted on these platforms (for example, suggested videos or by navigating to other videos hosted on the same site), are not within
the control or responsibility of SAP.

Programmers Guide for PHP


34 PUBLIC Important Disclaimers and Legal Information
Programmers Guide for PHP
Important Disclaimers and Legal Information PUBLIC 35
www.sap.com/contactsap

© 2020 SAP SE or an SAP affiliate company. All rights reserved.

No part of this publication may be reproduced or transmitted in any form


or for any purpose without the express permission of SAP SE or an SAP
affiliate company. The information contained herein may be changed
without prior notice.

Some software products marketed by SAP SE and its distributors


contain proprietary software components of other software vendors.
National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for


informational purposes only, without representation or warranty of any
kind, and SAP or its affiliated companies shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP or
SAP affiliate company products and services are those that are set forth
in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an
additional warranty.

SAP and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP
SE (or an SAP affiliate company) in Germany and other countries. All
other product and service names mentioned are the trademarks of their
respective companies.

Please see https://www.sap.com/about/legal/trademark.html for


additional trademark information and notices.

THE BEST RUN

You might also like