db2_set_option
Opis
bool db2_set_option ( resource resource, array options [, int type] )Sets options for a statement resource or a connection resource. You cannot set options for result set resources.
Parametry
resource
A valid statement resource as returned from db2_prepare() or a valid connection resource as returned from db2_connect() or db2_pconnect().
options
An associative array containing valid statement or connection options. This parameter can be used to change autocommit values, cursor types (scrollable or forward), and to specify the case of the column names (lower, upper, or natural) that will appear in a result set.
autocommit
Passing DB2_AUTOCOMMIT_ON turns autocommit on for the specified connection resource.
Passing DB2_AUTOCOMMIT_OFF turns autocommit off for the specified connection resource.
cursor
Passing DB2_FORWARD_ONLY specifies a forward-only cursor for a statement resource. This is the default cursor type, and is supported by all database servers.
Passing DB2_SCROLLABLE specifies a scrollable cursor for a statement resource. Scrollable cursors enable result set rows to be accessed in non-sequential order, but are only supported by IBM DB2 Universal Database databases.
binmode
Passing DB2_BINARY specifies that binary data will be returned as is. This is the default mode. This is the equivalent of setting ibm_db2.binmode=1 in php.ini.
Passing DB2_CONVERT specifies that binary data will be converted to hexadecimal encoding, and will be returned as such. This is the equivalent of setting ibm_db2.binmode=2 in php.ini.
Passing DB2_PASSTHRU specifies that binary data will be converted to NULL. This is the equivalent of setting ibm_db2.binmode=3 in php.ini.
db2_attr_case
Passing DB2_CASE_LOWER specifies that column names of the result set are returned in lower case.
Passing DB2_CASE_UPPER specifies that column names of the result set are returned in upper case.
Passing DB2_CASE_NATURAL specifies that column names of the result set are returned in natural case.
The following new i5/OS options are available as of ibm_db2 version 1.5.1. Note: prior versions of ibm_db2 do not support these new i5 options.
i5_fetch_only
DB2_I5_FETCH_ON - Cursors are read-only and cannot be used for positioned updates or deletes. This is the default unless SQL_ATTR_FOR_FETCH_ONLY environment has been set to SQL_FALSE.
DB2_I5_FETCH_OFF - Cursors can be used for positioned updates and deletes.
type
An integer value that specifies the type of resource that was passed into the function. The type of resource and this value must correspond.
Passing 1 as the value specifies that a connection resource has been passed into the function.
Passing any integer not equal to 1 as the value specifies that a statement resource has been passed into the function.
The following table specifies which options are compatible with the available resource types:
Tabela 1. Resource-Parameter Matrix
Key | Value | Resource Type | ||
---|---|---|---|---|
Connection | Statement | Result Set | ||
autocommit | DB2_AUTOCOMMIT_ON | X | - | - |
autocommit | DB2_AUTOCOMMIT_OFF | X | - | - |
cursor | DB2_SCROLLABLE | X | X | - |
cursor | DB2_FORWARD_ONLY | X | X | - |
binmode | DB2_BINARY | X | X | - |
binmode | DB2_CONVERT | X | X | - |
binmode | DB2_PASSTHRU | X | X | - |
db2_attr_case | DB2_CASE_LOWER | X | X | - |
db2_attr_case | DB2_CASE_UPPER | X | X | - |
db2_attr_case | DB2_CASE_NATURAL | X | X | - |
i5_fetch_only | DB2_I5_FETCH_ON | - | X | - |
i5_fetch_only | DB2_I5_FETCH_OFF | - | X | - |
Przykłady
Przykład 2. Setting multiple parameters with a connection resource
Powyższy przykład wyświetli:
|
Przykład 3. Setting multiple parameters with an invalid key
Powyższy przykład wyświetli:
|
Przykład 4. Setting multiple parameters with an invalid value
Powyższy przykład wyświetli:
|
Przykład 5. Setting multiple parameters with a connection resource and the wrong type
Powyższy przykład wyświetli:
|
Przykład 6. Setting multiple parameters with the wrong resource
Powyższy przykład wyświetli:
|
Przykład 7. Putting it all together
Powyższy przykład wyświetli:
|
Przykład 8. i5/OS cursors are read-only
Powyższy przykład wyświetli:
|
Poprzedni | Spis treści | Następny |
db2_server_info | Początek rozdziału |