PHP. Руководство по PHP. 2005
db2_connect
db2_connect
(no version information, might be only in CVS)db2_connect -- Returns a connection to a database
Описание
resource db2_connect (string database, string username, string password [, array options])Creates a new connection to an IBM DB2 Universal Database, IBM Cloudscape, or Apache Derby database.
Список параметров
database
For a cataloged connection to a database, database represents the database alias in the DB2 client catalog.
For an uncataloged connection to a database, database represents a complete connection string in the following format: DRIVER={IBM DB2 ODBC DRIVER};DATABASE=database;HOSTNAME=hostname;PORT=port;PROTOCOL=TCPIP;UID=username;PWD=password; where the parameters represent the following values:
database
The name of the database.
hostname
The hostname or IP address of the database server.
port
The TCP/IP port on which the database is listening for requests.
username
The username with which you are connecting to the database.
password
The password with which you are connecting to the database.
username
The username with which you are connecting to the database.
For uncataloged connections, you must pass a NULL value or empty string.
password
The password with which you are connecting to the database.
For uncataloged connections, you must pass a NULL value or empty string.
options
An associative array of connection options that affect the behavior of the connection, where valid array keys include:
autocommit
Passing the DB2_AUTOCOMMIT_ON value turns autocommit on for this connection handle.
Passing the DB2_AUTOCOMMIT_OFF value turns autocommit off for this connection handle.
Возвращаемые значения
Returns a connection handle resource if the connection attempt is successful. If the connection attempt fails, db2_connect() returns FALSE.
Примеры
Пример 2. Creating an uncataloged connection An uncataloged connection enables you to dynamically connect to a database.
Результат выполнения данного примера:
|
Пример 3. Creating a connection with autocommit off by default Passing an array of options to db2_connect() enables you to modify the default behavior of the connection handle.
Результат выполнения данного примера:
|
Смотрите также
db2_close() |
db2_pconnect() |
db2_conn_errormsg
db2_cursor_type