cvs: phpdoc /en/reference/ibm_db2 ini.xml /en/reference/ibm_db2/functions db2-connect.xml db2-fetch-row.xml db2-set-option.xml
| From: | Nuno Lopes | Date: | Thu, 09 Nov 2006 14:43:21 +0000 |
| Subject: | cvs: phpdoc /en/reference/ibm_db2 ini.xml /en/reference/ibm_db2/functions db2-connect.xml db2-fetch-row.xml db2-set-option.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969374350@lists.php.net to get a copy of this message | ||
nlopess Thu Nov 9 14:43:21 2006 UTC
Modified files:
/phpdoc/en/reference/ibm_db2 ini.xml
/phpdoc/en/reference/ibm_db2/functions db2-connect.xml
db2-fetch-row.xml
db2-set-option.xml
Log:
i5 options and examples. Patch by Owain Jones
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/ini.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/ibm_db2/ini.xml diff -u phpdoc/en/reference/ibm_db2/ini.xml:1.3 phpdoc/en/reference/ibm_db2/ini.xml:1.4 --- phpdoc/en/reference/ibm_db2/ini.xml:1.3 Wed Jul 20 18:45:50 2005 +++ phpdoc/en/reference/ibm_db2/ini.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <section id="extname.configuration"> &reftitle.runtime; &extension.runtime; @@ -23,6 +23,18 @@ <entry></entry> </row> <row> + <entry>ibm_db2.i5_allow_commit</entry> + <entry>"0"</entry> + <entry>PHP_INI_SYSTEM</entry> + <entry></entry> + </row> + <row> + <entry>ibm_db2.i5_dbcs_alloc</entry> + <entry>"0"</entry> + <entry>PHP_INI_SYSTEM</entry> + <entry></entry> + </row> + <row> <entry>ibm_db2.instance_name</entry> <entry>NULL</entry> <entry>PHP_INI_SYSTEM</entry> @@ -67,6 +79,54 @@ </para> </listitem> </varlistentry> + <varlistentry id="ini.ibm-db2.i5-allow-commit"> + <term> + <parameter>ibm_db2.i5_allow_commit</parameter> + <type>integer</type> + </term> + <listitem> + <para> + This option controls the commit mode used for i5 schema collections + in the PHP application. + <itemizedlist> + <listitem> + <para> + 0 no commit (see i5_commit for override) + </para> + </listitem> + <listitem> + <para> + 1 allow commit (see i5_commit for override) + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> + <varlistentry id="ini.ibm-db2.i5-dbcs-alloc"> + <term> + <parameter>ibm_db2.i5_dbcs_alloc</parameter> + <type>integer</type> + </term> + <listitem> + <para> + This option controls the internal ibm_db2 allocation scheme + for large DBCS column buffers. + <itemizedlist> + <listitem> + <para> + 0 no expanded allocations (see i5_dbcs_alloc for override) + </para> + </listitem> + <listitem> + <para> + 1 use expanded allocations (see i5_dbcs_alloc for override) + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> <varlistentry id="ini.ibm-db2.instance-name"> <term> <parameter>ibm_db2.instance_name</parameter> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-connect.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-connect.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.7 phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.8 --- phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.7 Tue Feb 21 16:42:41 2006 +++ phpdoc/en/reference/ibm_db2/functions/db2-connect.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. --> <refentry id="function.db2-connect"> <refnamediv> @@ -167,6 +167,233 @@ </varlistentry> </variablelist> </para> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>i5_lib</parameter></term> + <listitem> + <para> + A character value that indicates the default library that will be + used for resolving unqualified file references. This is not valid + if the connection is using system naming mode. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_naming</parameter></term> + <listitem> + <para> + <literal>DB2_I5_NAMING_ON</literal> value turns on DB2 UDB CLI iSeries + system naming mode. Files are qualified using the slash (/) delimiter. + Unqualified files are resolved using the library list for the job. + </para> + <para> + <literal>DB2_I5_NAMING_OFF</literal> value turns off DB2 UDB CLI default + naming mode, which is SQL naming. Files are qualified using the period (.) + delimiter. Unqualified files are resolved using either the default library + or the current user ID. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_commit</parameter></term> + <listitem> + <para> + The <parameter>i5_commit</parameter> attribute should be set before the + <function>db2_connect</function>. If the value is changed after the + connection has been established, and the connection is to a remote data + source, the change does not take effect until the next successful + <function>db2_connect</function> for the connection handle. + </para> + <para> + Note: php.ini setting <parameter>ibm_db2.i5_allow_commit</parameter>==0 + or <literal>DB2_I5_TXN_NO_COMMIT</literal> is the default, but may be + overridden with the <parameter>i5_commit</parameter> option. + </para> + <para> + <literal>DB2_I5_TXN_NO_COMMIT</literal> - Commitment control is not used. + </para> + <para> + <literal>DB2_I5_TXN_READ_UNCOMMITTED</literal> - Dirty reads, nonrepeatable + reads, and phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_READ_COMMITTED</literal> - Dirty reads are not possible. + Nonrepeatable reads, and phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_REPEATABLE_READ</literal> - Dirty reads and nonrepeatable + reads are not possible. Phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_SERIALIZABLE</literal> - Transactions are serializable. + Dirty reads, non-repeatable reads, and phantoms are not possible + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_query_optimize</parameter></term> + <listitem> + <para> + <literal>DB2_FIRST_IO</literal> All queries are optimized with the goal of + returning the first page of output as fast as possible. This goal works well + when the output is controlled by a user who is most likely to cancel the query + after viewing the first page of output data. Queries coded with an + OPTIMIZE FOR nnn ROWS clause honor the goal specified by the clause. + </para> + <para> + <literal>DB2_ALL_IO All</literal> queries are optimized with the goal of running + the entire query to completion in the shortest amount of elapsed time. This is a + good option when the output of a query is being written to a file or report, or + the interface is queuing the output data. Queries coded with an OPTIMIZE FOR nnn + ROWS clause honor the goal specified by the clause. This is the default. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_dbcs_alloc</parameter></term> + <listitem> + <para> + <literal>DB2_I5_DBCS_ALLOC_ON</literal> value turns on DB2 6X allocation scheme + for DBCS translation column size growth. + </para> + <para> + <literal>DB2_I5_DBCS_ALLOC_OFF</literal> value turns off DB2 6X allocation scheme + for DBCS translation column size growth. + </para> + <para> + Note: php.ini setting <parameter>ibm_db2.i5_dbcs_alloc</parameter>==0 or + <literal>DB2_I5_DBCS_ALLOC_OFF</literal> is the default, but may be overridden + with the <parameter>i5_dbcs_alloc</parameter> option. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_date_fmt</parameter></term> + <listitem> + <para> + <literal>SQL_FMT_ISO</literal> - The International Organization for Standardization + (ISO) date format yyyy-mm-dd is used. This is the default. + </para> + <para> + <literal>DB2_I5_FMT_USA</literal> - The United States date format mm/dd/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_EUR</literal> - The European date format dd.mm.yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_JIS</literal> - The Japanese Industrial Standard date format + yyyy-mm-dd is used. + </para> + <para> + <literal>DB2_I5_FMT_MDY</literal> - The date format mm/dd/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_DMY</literal> - The date format dd/mm/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_YMD</literal> - The date format yy/mm/dd is used. + </para> + <para> + <literal>DB2_I5_FMT_JUL</literal> - The Julian date format yy/ddd is used. + </para> + <para> + <literal>DB2_I5_FMT_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_date_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_SLASH</literal> - A slash ( / ) is used as the date separator. + This is the default. + </para> + <para> + <literal>DB2_I5_SEP_DASH</literal> - A dash ( - ) is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as the date + separator. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_BLANK</literal> - A blank is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_time_fmt</parameter></term> + <listitem> + <para> + <literal>DB2_I5_FMT_ISO</literal> - The International Organization for + Standardization (ISO) time format hh.mm.ss is used. This is the default. + </para> + <para> + <literal>DB2_I5_FMT_USA</literal> - The United States time format + hh:mmxx is used, where xx is AM or PM. + </para> + <para> + <literal>DB2_I5_FMT_EUR</literal> - The European time format hh.mm.ss + is used. + </para> + <para> + <literal>DB2_I5_FMT_JIS</literal> - The Japanese Industrial Standard + time format hh:mm:ss is used. + </para> + <para> + <literal>DB2_I5_FMT_HMS</literal> - The hh:mm:ss format is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_time_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_COLON</literal> - A colon ( : ) is used as the time + separator. This is the default. + </para> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as the time + separator. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the time + separator. + </para> + <para> + <literal>DB2_I5_SEP_BLANK</literal> - A blank is used as the time separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_decimal_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as + the decimal separator. This is the default. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the + date separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> </listitem> </varlistentry> </variablelist> @@ -293,7 +520,36 @@ ]]> </screen> </example> - + <example> + <title>i5/OS best performance</title> + <para> + To achieve best performance for your i5/OS ibm_db2 1.5.1 PHP application + use the default host, userid, and password for your + <function>db2_connect</function>. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $library = "ADC"; + $i5 = db2_connect("", "", "", array("i5_lib"=>"qsys2")); + $result = db2_exec($i5, + "select * from systables where table_schema = '$library'"); + while ($row = db2_fetch_both($result)) { + echo $row['TABLE_NAME']."</br>"; + } + db2_close($i5); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +ANIMALS +NAMES +PICTURES +]]> + </screen> + </example> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.5 phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.6 --- phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.5 Tue Jul 12 17:39:24 2005 +++ phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. --> <refentry id="function.db2-fetch-row"> <refnamediv> @@ -101,6 +101,52 @@ ]]> </screen> </example> + <example> + <title>i5/OS recommended alternatives to db2_fetch_row/db2_result</title> + <para> + On i5/OS it is recommended that you use <function>db2_fetch_both</function>, + <function>db2_fetch_array</function>, or <function>db2_fetch_object</function> + over <function>db2_fetch_row</function>/<function>db2_result</function>. In general + <function>db2_fetch_row</function>/<function>db2_result</function> have more issues + with various column types in <literal>EBCIDIC</literal> to <literal>ASCII</literal> + translation, including possible truncation in <literal>DBCS</literal> applications. + You may also find the performance of <function>db2_fetch_both</function>, + <function>db2_fetch_array</function>, and <function>db2_fetch_object</function> to + be superior to <function>db2_fetch_row</function>/<function>db2_result</function>. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $conn = db2_connect("","",""); + $sql = 'SELECT SPECIFIC_SCHEMA, SPECIFIC_NAME, ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, ROUTINE_CREATED, ROUTINE_BODY, IN_PARMS, OUT_PARMS, INOUT_PARMS, PARAMETER_STYLE, EXTERNAL_NAME, EXTERNAL_LANGUAGE FROM QSYS2.SYSROUTINES FETCH FIRST 2 ROWS ONLY'; + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_both($stmt)){ + echo "<br>db2_fetch_both {$row['SPECIFIC_NAME']} {$row['ROUTINE_CREATED']} {$row[5]}"; + } + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_array($stmt)){ + echo "<br>db2_fetch_array {$row[1]} {$row[5]}"; + } + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_object($stmt)){ + echo "<br>db2_fetch_object {$row->SPECIFIC_NAME} {$row->ROUTINE_CREATED}"; + } + db2_close($conn); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +db2_fetch_both MATCH_ANIMAL 2006-08-25-17.10.23.775000 2006-08-25-17.10.23.775000 +db2_fetch_both MULTIRESULTS 2006-10-17-10.11.05.308000 2006-10-17-10.11.05.308000 +db2_fetch_array MATCH_ANIMAL 2006-08-25-17.10.23.775000 +db2_fetch_array MULTIRESULTS 2006-10-17-10.11.05.308000 +db2_fetch_object MATCH_ANIMAL 2006-08-25-17.10.23.775000 +db2_fetch_object MULTIRESULTS 2006-10-17-10.11.05.308000 +]]> + </screen> + </example> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.3 phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.4 --- phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.3 Wed Oct 4 00:44:12 2006 +++ phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml Thu Nov 9 14:43:20 2006 @@ -1,676 +1,739 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> -<refentry id="function.db2-set-option"> - <refnamediv> - <refname>db2_set_option</refname> - <refpurpose>Set options for connection or statement resources</refpurpose> - </refnamediv> - <refsect1 role="description"> - &reftitle.description; - <methodsynopsis> - <!-- All Functions have this --> - <type>bool</type><methodname>db2_set_option</methodname> - - <!-- Required Parameter (First Param) --> - <methodparam><type>resource</type><parameter>resource</parameter></methodparam> - - <!-- Required Parameter (Second Param) --> - <methodparam><type>array</type><parameter>options</parameter></methodparam> - - <!-- Optional Parameter (Third Param) --> - <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> - </methodsynopsis> - <para> - Sets options for a statement resource or a connection resource. You - cannot set options for result set resources. - </para> - </refsect1> - <refsect1 role="parameters"> - &reftitle.parameters; - <para> - <variablelist> - <varlistentry> - <term><parameter>resource</parameter></term> - <listitem> - <para> - A valid statement resource as returned from - <function>db2_prepare</function> or a valid connection resource as - returned from <function>db2_connect</function> or - <function>db2_pconnect</function>. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>options</parameter></term> - <listitem> - <para> - 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. - <variablelist> - <varlistentry> - <term><parameter>autocommit</parameter></term> - <listitem> - <para> - Passing <literal>DB2_AUTOCOMMIT_ON</literal> turns - autocommit on for the specified connection resource. - </para> - <para> - Passing <literal>DB2_AUTOCOMMIT_OFF</literal> turns - autocommit off for the specified connection resource. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>cursor</parameter></term> - <listitem> - <para> - Passing <literal>DB2_FORWARD_ONLY</literal> specifies a - forward-only cursor for a statement resource. This is the - default cursor type, and is supported by all database - servers. - </para> - <para> - Passing <literal>DB2_SCROLLABLE</literal> 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. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>binmode</parameter></term> - <listitem> - <para> - Passing <literal>DB2_BINARY</literal> specifies that - binary data will be returned as is. This is the default - mode. This is the equivalent of setting - <literal>ibm_db2.binmode=1</literal> in &php.ini;. - </para> - <para> - Passing <literal>DB2_CONVERT</literal> specifies that - binary data will be converted to hexadecimal encoding, - and will be returned as such. This is the equivalent of - setting <literal>ibm_db2.binmode=2</literal> in &php.ini;. - </para> - <para> - Passing <literal>DB2_PASSTHRU</literal> specifies that - binary data will be converted to &null;. This is the - equivalent of setting <literal>ibm_db2.binmode=3</literal> - in &php.ini;. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>db2_attr_case</parameter></term> - <listitem> - <para> - Passing <literal>DB2_CASE_LOWER</literal> specifies that - column names of the result set are returned in lower case. - </para> - <para> - Passing <literal>DB2_CASE_UPPER</literal> specifies that - column names of the result set are returned in upper case. - </para> - <para> - Passing <literal>DB2_CASE_NATURAL</literal> specifies that - column names of the result set are returned in natural - case. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>type</parameter></term> - <listitem> - <para> - An integer value that specifies the type of resource that was - passed into the function. The type of resource and this value - must correspond. - <variablelist> - <varlistentry> - <term><parameter></parameter></term> - <listitem> - <para> - Passing <literal>1</literal> as the value specifies that - a connection resource has been passed into the function. - </para> - <para> - Passing any integer not equal to <literal>1</literal> as - the value specifies that a statement resource has been - passed into the function. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - <para> - </para> - <para> - The following table specifies which options are compatible with - the available resource types: - <table> - <title>Resource-Parameter Matrix</title> - <tgroup cols="5"> - <colspec colnum="1" colname="col1" align="center" /> - <colspec colnum="2" colname="col2" align="center" /> - <colspec colnum="3" colname="col3" align="center" /> - <colspec colnum="4" colname="col4" align="center" /> - <colspec colnum="5" colname="col5" align="center" /> - - <thead> - <row> - <entry morerows="1">Key</entry> - <entry morerows="1">Value</entry> - <entry namest="col3" nameend="col5">Resource Type</entry> - </row> - </thead> - - <tbody> - <row> - <entry colname="col3">Connection</entry> - <entry colname="col4">Statement</entry> - <entry colname="col5">Result Set</entry> - </row> - <row> - <entry>autocommit</entry> - <entry><literal>DB2_AUTOCOMMIT_ON</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">-</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>autocommit</entry> - <entry><literal>DB2_AUTOCOMMIT_OFF</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">-</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>cursor</entry> - <entry><literal>DB2_SCROLLABLE</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>cursor</entry> - <entry><literal>DB2_FORWARD_ONLY</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_BINARY</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_CONVERT</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_PASSTHRU</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_LOWER</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_UPPER</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_NATURAL</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - </tbody> - </tgroup> - </table> - </para> - </refsect1> - - <refsect1 role="returnvalues"> - &reftitle.returnvalues; - <para> - &return.success; - </para> - </refsect1> - <!-- Place Changelog next if any --> - - <!-- Place Examples next if any --> - <refsect1 role="examples"> - &reftitle.examples; - <para> - - <example> - <title>Setting one parameter with a connection resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_ON); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Options Set Successfully]]></screen> - </example> - - <example> - <title>Setting multiple parameters with a connection resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Options Set Successfully]]></screen> - </example> - - <!-- Behaves Incorrectly --> - <example> - <title>Setting multiple parameters with an invalid key</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'MY_INVALID_KEY' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <!-- Behaves Incorrectly --> - <example> - <title>Setting multiple parameters with an invalid value</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => 'INVALID_VALUE', - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Setting multiple parameters with a connection resource and the wrong type</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and the wrong type value */ -$result = db2_set_option($conn, $options, 2); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Setting multiple parameters with the wrong resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE'); - -/* Call the function using the wrong resource, and the correct options array, and type values */ -$result = db2_set_option($stmt, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Putting it all together</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('db2_attr_case' => DB2_CASE_LOWER, - 'cursor' => DB2_SCROLLABLE); - -$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE WHERE EMPNO = ? OR EMPNO = ?'); - -/* Call the function using the correct resource, options array, and type values */ -$option_result = db2_set_option($stmt, $options, 2); -$result = db2_execute($stmt, array('000130', '000140')); - -/* Get Row 2 before Row 1 since Scrollable Cursor */ -print_r(db2_fetch_assoc($stmt, 2)); -print '<br /><br />'; -print_r(db2_fetch_assoc($stmt, 1)); - -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Array -( - [empno] => 000140 - [firstnme] => HEATHER - [midinit] => A - [lastname] => NICHOLLS - [workdept] => C01 - [phoneno] => 1793 - [hiredate] => 1976-12-15 - [job] => ANALYST - [edlevel] => 18 - [sex] => F - [birthdate] => 1946-01-19 - [salary] => 28420.00 - [bonus] => 600.00 - [comm] => 2274.00 -) - -Array -( - [empno] => 000130 - [firstnme] => DELORES - [midinit] => M - [lastname] => QUINTANA - [workdept] => C01 - [phoneno] => 4578 - [hiredate] => 1971-07-28 - [job] => ANALYST - [edlevel] => 16 - [sex] => F - [birthdate] => 1925-09-15 - [salary] => 23800.00 - [bonus] => 500.00 - [comm] => 1904.00 -)]]></screen> - </example> - </para> - </refsect1> - <refsect1 role="seealso"> - &reftitle.seealso; - <para> - <simplelist> - <member><function>db2_connect</function></member> - <member><function>db2_pconnect</function></member> - <member><function>db2_exec</function></member> - <member><function>db2_prepare</function></member> - <member><function>db2_cursor_type</function></member> - </simplelist> - </para> - </refsect1> -</refentry> - -<!-- Keep this comment at the end of the file -Local variables: -mode: sgml -sgml-omittag:t -sgml-shorttag:t -sgml-minimize-attributes:nil -sgml-always-quote-attributes:t -sgml-indent-step:1 -sgml-indent-data:t -indent-tabs-mode:nil -sgml-parent-document:nil -sgml-default-dtd-file:"../../../../manual.ced" -sgml-exposed-tags:nil -sgml-local-catalogs:nil -sgml-local-ecat-files:nil -End: -vim600: syn=xml fen fdm=syntax fdl=2 si -vim: et tw=78 syn=sgml -vi: ts=1 sw=1 ---> +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- $Revision: 1.4 $ --> +<refentry id="function.db2-set-option"> + <refnamediv> + <refname>db2_set_option</refname> + <refpurpose>Set options for connection or statement resources</refpurpose> + </refnamediv> + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <!-- All Functions have this --> + <type>bool</type><methodname>db2_set_option</methodname> + + <!-- Required Parameter (First Param) --> + <methodparam><type>resource</type><parameter>resource</parameter></methodparam> + + <!-- Required Parameter (Second Param) --> + <methodparam><type>array</type><parameter>options</parameter></methodparam> + + <!-- Optional Parameter (Third Param) --> + <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> + </methodsynopsis> + <para> + Sets options for a statement resource or a connection resource. You + cannot set options for result set resources. + </para> + </refsect1> + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>resource</parameter></term> + <listitem> + <para> + A valid statement resource as returned from + <function>db2_prepare</function> or a valid connection resource as + returned from <function>db2_connect</function> or + <function>db2_pconnect</function>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>options</parameter></term> + <listitem> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>autocommit</parameter></term> + <listitem> + <para> + Passing <literal>DB2_AUTOCOMMIT_ON</literal> turns + autocommit on for the specified connection resource. + </para> + <para> + Passing <literal>DB2_AUTOCOMMIT_OFF</literal> turns + autocommit off for the specified connection resource. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>cursor</parameter></term> + <listitem> + <para> + Passing <literal>DB2_FORWARD_ONLY</literal> specifies a + forward-only cursor for a statement resource. This is the + default cursor type, and is supported by all database + servers. + </para> + <para> + Passing <literal>DB2_SCROLLABLE</literal> 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. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>binmode</parameter></term> + <listitem> + <para> + Passing <literal>DB2_BINARY</literal> specifies that + binary data will be returned as is. This is the default + mode. This is the equivalent of setting + <literal>ibm_db2.binmode=1</literal> in &php.ini;. + </para> + <para> + Passing <literal>DB2_CONVERT</literal> specifies that + binary data will be converted to hexadecimal encoding, + and will be returned as such. This is the equivalent of + setting <literal>ibm_db2.binmode=2</literal> in &php.ini;. + </para> + <para> + Passing <literal>DB2_PASSTHRU</literal> specifies that + binary data will be converted to &null;. This is the + equivalent of setting <literal>ibm_db2.binmode=3</literal> + in &php.ini;. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>db2_attr_case</parameter></term> + <listitem> + <para> + Passing <literal>DB2_CASE_LOWER</literal> specifies that + column names of the result set are returned in lower case. + </para> + <para> + Passing <literal>DB2_CASE_UPPER</literal> specifies that + column names of the result set are returned in upper case. + </para> + <para> + Passing <literal>DB2_CASE_NATURAL</literal> specifies that + column names of the result set are returned in natural + case. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>i5_fetch_only</parameter></term> + <listitem> + <para> + <literal>DB2_I5_FETCH_ON</literal> - Cursors are read-only + and cannot be used for positioned updates or deletes. This + is the default unless <literal>SQL_ATTR_FOR_FETCH_ONLY</literal> + environment has been set to <literal>SQL_FALSE</literal>. + </para> + <para> + <literal>DB2_I5_FETCH_OFF</literal> - Cursors can be used + for positioned updates and deletes. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>type</parameter></term> + <listitem> + <para> + An integer value that specifies the type of resource that was + passed into the function. The type of resource and this value + must correspond. + <variablelist> + <varlistentry> + <term><parameter></parameter></term> + <listitem> + <para> + Passing <literal>1</literal> as the value specifies that + a connection resource has been passed into the function. + </para> + <para> + Passing any integer not equal to <literal>1</literal> as + the value specifies that a statement resource has been + passed into the function. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + </para> + <para> + The following table specifies which options are compatible with + the available resource types: + <table> + <title>Resource-Parameter Matrix</title> + <tgroup cols="5"> + <colspec colnum="1" colname="col1" align="center" /> + <colspec colnum="2" colname="col2" align="center" /> + <colspec colnum="3" colname="col3" align="center" /> + <colspec colnum="4" colname="col4" align="center" /> + <colspec colnum="5" colname="col5" align="center" /> + + <thead> + <row> + <entry morerows="1">Key</entry> + <entry morerows="1">Value</entry> + <entry namest="col3" nameend="col5">Resource Type</entry> + </row> + </thead> + + <tbody> + <row> + <entry colname="col3">Connection</entry> + <entry colname="col4">Statement</entry> + <entry colname="col5">Result Set</entry> + </row> + <row> + <entry>autocommit</entry> + <entry><literal>DB2_AUTOCOMMIT_ON</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>autocommit</entry> + <entry><literal>DB2_AUTOCOMMIT_OFF</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>cursor</entry> + <entry><literal>DB2_SCROLLABLE</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>cursor</entry> + <entry><literal>DB2_FORWARD_ONLY</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_BINARY</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_CONVERT</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_PASSTHRU</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_LOWER</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_UPPER</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_NATURAL</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>i5_fetch_only</entry> + <entry><literal>DB2_I5_FETCH_ON</literal></entry> + <entry colname="col3">-</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>i5_fetch_only</entry> + <entry><literal>DB2_I5_FETCH_OFF</literal></entry> + <entry colname="col3">-</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + &return.success; + </para> + </refsect1> + <!-- Place Changelog next if any --> + + <!-- Place Examples next if any --> + <refsect1 role="examples"> + &reftitle.examples; + <para> + + <example> + <title>Setting one parameter with a connection resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_ON); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Options Set Successfully]]></screen> + </example> + + <example> + <title>Setting multiple parameters with a connection resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Options Set Successfully]]></screen> + </example> + + <!-- Behaves Incorrectly --> + <example> + <title>Setting multiple parameters with an invalid key</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'MY_INVALID_KEY' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <!-- Behaves Incorrectly --> + <example> + <title>Setting multiple parameters with an invalid value</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => 'INVALID_VALUE', + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Setting multiple parameters with a connection resource and the wrong type</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and the wrong type value */ +$result = db2_set_option($conn, $options, 2); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Setting multiple parameters with the wrong resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE'); + +/* Call the function using the wrong resource, and the correct options array, and type values */ +$result = db2_set_option($stmt, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Putting it all together</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('db2_attr_case' => DB2_CASE_LOWER, + 'cursor' => DB2_SCROLLABLE); + +$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE WHERE EMPNO = ? OR EMPNO = ?'); + +/* Call the function using the correct resource, options array, and type values */ +$option_result = db2_set_option($stmt, $options, 2); +$result = db2_execute($stmt, array('000130', '000140')); + +/* Get Row 2 before Row 1 since Scrollable Cursor */ +print_r(db2_fetch_assoc($stmt, 2)); +print '<br /><br />'; +print_r(db2_fetch_assoc($stmt, 1)); + +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Array +( + [empno] => 000140 + [firstnme] => HEATHER + [midinit] => A + [lastname] => NICHOLLS + [workdept] => C01 + [phoneno] => 1793 + [hiredate] => 1976-12-15 + [job] => ANALYST + [edlevel] => 18 + [sex] => F + [birthdate] => 1946-01-19 + [salary] => 28420.00 + [bonus] => 600.00 + [comm] => 2274.00 +) + +Array +( + [empno] => 000130 + [firstnme] => DELORES + [midinit] => M + [lastname] => QUINTANA + [workdept] => C01 + [phoneno] => 4578 + [hiredate] => 1971-07-28 + [job] => ANALYST + [edlevel] => 16 + [sex] => F + [birthdate] => 1925-09-15 + [salary] => 23800.00 + [bonus] => 500.00 + [comm] => 1904.00 +)]]></screen> + </example> + <example> + <title>i5/OS cursors are read-only</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $conn = db2_connect("", "", "", array("i5_lib"=>"nobody")); + $stmt = db2_prepare($conn, 'select * from names where first = ?'); + $name = "first2"; + db2_bind_param($stmt, 1, "name", DB2_PARAM_IN); + $options = array("i5_fetch_only"=>DB2_I5_FETCH_ON); + db2_set_option($stmt,$options,0); + if (db2_execute($stmt)) { + while ($row = db2_fetch_array($stmt)) { + echo "{$row[0]} {$row[1]}"; + } + } +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +first2 last2 +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>db2_connect</function></member> + <member><function>db2_pconnect</function></member> + <member><function>db2_exec</function></member> + <member><function>db2_prepare</function></member> + <member><function>db2_cursor_type</function></member> + </simplelist> + </para> + </refsect1> +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +-->
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/ini.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/ibm_db2/ini.xml diff -u phpdoc/en/reference/ibm_db2/ini.xml:1.3 phpdoc/en/reference/ibm_db2/ini.xml:1.4 --- phpdoc/en/reference/ibm_db2/ini.xml:1.3 Wed Jul 20 18:45:50 2005 +++ phpdoc/en/reference/ibm_db2/ini.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <section id="extname.configuration"> &reftitle.runtime; &extension.runtime; @@ -23,6 +23,18 @@ <entry></entry> </row> <row> + <entry>ibm_db2.i5_allow_commit</entry> + <entry>"0"</entry> + <entry>PHP_INI_SYSTEM</entry> + <entry></entry> + </row> + <row> + <entry>ibm_db2.i5_dbcs_alloc</entry> + <entry>"0"</entry> + <entry>PHP_INI_SYSTEM</entry> + <entry></entry> + </row> + <row> <entry>ibm_db2.instance_name</entry> <entry>NULL</entry> <entry>PHP_INI_SYSTEM</entry> @@ -67,6 +79,54 @@ </para> </listitem> </varlistentry> + <varlistentry id="ini.ibm-db2.i5-allow-commit"> + <term> + <parameter>ibm_db2.i5_allow_commit</parameter> + <type>integer</type> + </term> + <listitem> + <para> + This option controls the commit mode used for i5 schema collections + in the PHP application. + <itemizedlist> + <listitem> + <para> + 0 no commit (see i5_commit for override) + </para> + </listitem> + <listitem> + <para> + 1 allow commit (see i5_commit for override) + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> + <varlistentry id="ini.ibm-db2.i5-dbcs-alloc"> + <term> + <parameter>ibm_db2.i5_dbcs_alloc</parameter> + <type>integer</type> + </term> + <listitem> + <para> + This option controls the internal ibm_db2 allocation scheme + for large DBCS column buffers. + <itemizedlist> + <listitem> + <para> + 0 no expanded allocations (see i5_dbcs_alloc for override) + </para> + </listitem> + <listitem> + <para> + 1 use expanded allocations (see i5_dbcs_alloc for override) + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> <varlistentry id="ini.ibm-db2.instance-name"> <term> <parameter>ibm_db2.instance_name</parameter> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-connect.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-connect.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.7 phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.8 --- phpdoc/en/reference/ibm_db2/functions/db2-connect.xml:1.7 Tue Feb 21 16:42:41 2006 +++ phpdoc/en/reference/ibm_db2/functions/db2-connect.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. --> <refentry id="function.db2-connect"> <refnamediv> @@ -167,6 +167,233 @@ </varlistentry> </variablelist> </para> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>i5_lib</parameter></term> + <listitem> + <para> + A character value that indicates the default library that will be + used for resolving unqualified file references. This is not valid + if the connection is using system naming mode. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_naming</parameter></term> + <listitem> + <para> + <literal>DB2_I5_NAMING_ON</literal> value turns on DB2 UDB CLI iSeries + system naming mode. Files are qualified using the slash (/) delimiter. + Unqualified files are resolved using the library list for the job. + </para> + <para> + <literal>DB2_I5_NAMING_OFF</literal> value turns off DB2 UDB CLI default + naming mode, which is SQL naming. Files are qualified using the period (.) + delimiter. Unqualified files are resolved using either the default library + or the current user ID. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_commit</parameter></term> + <listitem> + <para> + The <parameter>i5_commit</parameter> attribute should be set before the + <function>db2_connect</function>. If the value is changed after the + connection has been established, and the connection is to a remote data + source, the change does not take effect until the next successful + <function>db2_connect</function> for the connection handle. + </para> + <para> + Note: php.ini setting <parameter>ibm_db2.i5_allow_commit</parameter>==0 + or <literal>DB2_I5_TXN_NO_COMMIT</literal> is the default, but may be + overridden with the <parameter>i5_commit</parameter> option. + </para> + <para> + <literal>DB2_I5_TXN_NO_COMMIT</literal> - Commitment control is not used. + </para> + <para> + <literal>DB2_I5_TXN_READ_UNCOMMITTED</literal> - Dirty reads, nonrepeatable + reads, and phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_READ_COMMITTED</literal> - Dirty reads are not possible. + Nonrepeatable reads, and phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_REPEATABLE_READ</literal> - Dirty reads and nonrepeatable + reads are not possible. Phantoms are possible. + </para> + <para> + <literal>DB2_I5_TXN_SERIALIZABLE</literal> - Transactions are serializable. + Dirty reads, non-repeatable reads, and phantoms are not possible + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_query_optimize</parameter></term> + <listitem> + <para> + <literal>DB2_FIRST_IO</literal> All queries are optimized with the goal of + returning the first page of output as fast as possible. This goal works well + when the output is controlled by a user who is most likely to cancel the query + after viewing the first page of output data. Queries coded with an + OPTIMIZE FOR nnn ROWS clause honor the goal specified by the clause. + </para> + <para> + <literal>DB2_ALL_IO All</literal> queries are optimized with the goal of running + the entire query to completion in the shortest amount of elapsed time. This is a + good option when the output of a query is being written to a file or report, or + the interface is queuing the output data. Queries coded with an OPTIMIZE FOR nnn + ROWS clause honor the goal specified by the clause. This is the default. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_dbcs_alloc</parameter></term> + <listitem> + <para> + <literal>DB2_I5_DBCS_ALLOC_ON</literal> value turns on DB2 6X allocation scheme + for DBCS translation column size growth. + </para> + <para> + <literal>DB2_I5_DBCS_ALLOC_OFF</literal> value turns off DB2 6X allocation scheme + for DBCS translation column size growth. + </para> + <para> + Note: php.ini setting <parameter>ibm_db2.i5_dbcs_alloc</parameter>==0 or + <literal>DB2_I5_DBCS_ALLOC_OFF</literal> is the default, but may be overridden + with the <parameter>i5_dbcs_alloc</parameter> option. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_date_fmt</parameter></term> + <listitem> + <para> + <literal>SQL_FMT_ISO</literal> - The International Organization for Standardization + (ISO) date format yyyy-mm-dd is used. This is the default. + </para> + <para> + <literal>DB2_I5_FMT_USA</literal> - The United States date format mm/dd/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_EUR</literal> - The European date format dd.mm.yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_JIS</literal> - The Japanese Industrial Standard date format + yyyy-mm-dd is used. + </para> + <para> + <literal>DB2_I5_FMT_MDY</literal> - The date format mm/dd/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_DMY</literal> - The date format dd/mm/yyyy is used. + </para> + <para> + <literal>DB2_I5_FMT_YMD</literal> - The date format yy/mm/dd is used. + </para> + <para> + <literal>DB2_I5_FMT_JUL</literal> - The Julian date format yy/ddd is used. + </para> + <para> + <literal>DB2_I5_FMT_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_date_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_SLASH</literal> - A slash ( / ) is used as the date separator. + This is the default. + </para> + <para> + <literal>DB2_I5_SEP_DASH</literal> - A dash ( - ) is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as the date + separator. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_BLANK</literal> - A blank is used as the date separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_time_fmt</parameter></term> + <listitem> + <para> + <literal>DB2_I5_FMT_ISO</literal> - The International Organization for + Standardization (ISO) time format hh.mm.ss is used. This is the default. + </para> + <para> + <literal>DB2_I5_FMT_USA</literal> - The United States time format + hh:mmxx is used, where xx is AM or PM. + </para> + <para> + <literal>DB2_I5_FMT_EUR</literal> - The European time format hh.mm.ss + is used. + </para> + <para> + <literal>DB2_I5_FMT_JIS</literal> - The Japanese Industrial Standard + time format hh:mm:ss is used. + </para> + <para> + <literal>DB2_I5_FMT_HMS</literal> - The hh:mm:ss format is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_time_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_COLON</literal> - A colon ( : ) is used as the time + separator. This is the default. + </para> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as the time + separator. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the time + separator. + </para> + <para> + <literal>DB2_I5_SEP_BLANK</literal> - A blank is used as the time separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i5_decimal_sep</parameter></term> + <listitem> + <para> + <literal>DB2_I5_SEP_PERIOD</literal> - A period ( . ) is used as + the decimal separator. This is the default. + </para> + <para> + <literal>DB2_I5_SEP_COMMA</literal> - A comma ( , ) is used as the + date separator. + </para> + <para> + <literal>DB2_I5_SEP_JOB</literal> - The job default is used. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> </listitem> </varlistentry> </variablelist> @@ -293,7 +520,36 @@ ]]> </screen> </example> - + <example> + <title>i5/OS best performance</title> + <para> + To achieve best performance for your i5/OS ibm_db2 1.5.1 PHP application + use the default host, userid, and password for your + <function>db2_connect</function>. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $library = "ADC"; + $i5 = db2_connect("", "", "", array("i5_lib"=>"qsys2")); + $result = db2_exec($i5, + "select * from systables where table_schema = '$library'"); + while ($row = db2_fetch_both($result)) { + echo $row['TABLE_NAME']."</br>"; + } + db2_close($i5); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +ANIMALS +NAMES +PICTURES +]]> + </screen> + </example> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.5 phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.6 --- phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml:1.5 Tue Jul 12 17:39:24 2005 +++ phpdoc/en/reference/ibm_db2/functions/db2-fetch-row.xml Thu Nov 9 14:43:20 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. --> <refentry id="function.db2-fetch-row"> <refnamediv> @@ -101,6 +101,52 @@ ]]> </screen> </example> + <example> + <title>i5/OS recommended alternatives to db2_fetch_row/db2_result</title> + <para> + On i5/OS it is recommended that you use <function>db2_fetch_both</function>, + <function>db2_fetch_array</function>, or <function>db2_fetch_object</function> + over <function>db2_fetch_row</function>/<function>db2_result</function>. In general + <function>db2_fetch_row</function>/<function>db2_result</function> have more issues + with various column types in <literal>EBCIDIC</literal> to <literal>ASCII</literal> + translation, including possible truncation in <literal>DBCS</literal> applications. + You may also find the performance of <function>db2_fetch_both</function>, + <function>db2_fetch_array</function>, and <function>db2_fetch_object</function> to + be superior to <function>db2_fetch_row</function>/<function>db2_result</function>. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $conn = db2_connect("","",""); + $sql = 'SELECT SPECIFIC_SCHEMA, SPECIFIC_NAME, ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, ROUTINE_CREATED, ROUTINE_BODY, IN_PARMS, OUT_PARMS, INOUT_PARMS, PARAMETER_STYLE, EXTERNAL_NAME, EXTERNAL_LANGUAGE FROM QSYS2.SYSROUTINES FETCH FIRST 2 ROWS ONLY'; + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_both($stmt)){ + echo "<br>db2_fetch_both {$row['SPECIFIC_NAME']} {$row['ROUTINE_CREATED']} {$row[5]}"; + } + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_array($stmt)){ + echo "<br>db2_fetch_array {$row[1]} {$row[5]}"; + } + $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE)); + while ($row = db2_fetch_object($stmt)){ + echo "<br>db2_fetch_object {$row->SPECIFIC_NAME} {$row->ROUTINE_CREATED}"; + } + db2_close($conn); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +db2_fetch_both MATCH_ANIMAL 2006-08-25-17.10.23.775000 2006-08-25-17.10.23.775000 +db2_fetch_both MULTIRESULTS 2006-10-17-10.11.05.308000 2006-10-17-10.11.05.308000 +db2_fetch_array MATCH_ANIMAL 2006-08-25-17.10.23.775000 +db2_fetch_array MULTIRESULTS 2006-10-17-10.11.05.308000 +db2_fetch_object MATCH_ANIMAL 2006-08-25-17.10.23.775000 +db2_fetch_object MULTIRESULTS 2006-10-17-10.11.05.308000 +]]> + </screen> + </example> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml diff -u phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.3 phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.4 --- phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml:1.3 Wed Oct 4 00:44:12 2006 +++ phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml Thu Nov 9 14:43:20 2006 @@ -1,676 +1,739 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> -<refentry id="function.db2-set-option"> - <refnamediv> - <refname>db2_set_option</refname> - <refpurpose>Set options for connection or statement resources</refpurpose> - </refnamediv> - <refsect1 role="description"> - &reftitle.description; - <methodsynopsis> - <!-- All Functions have this --> - <type>bool</type><methodname>db2_set_option</methodname> - - <!-- Required Parameter (First Param) --> - <methodparam><type>resource</type><parameter>resource</parameter></methodparam> - - <!-- Required Parameter (Second Param) --> - <methodparam><type>array</type><parameter>options</parameter></methodparam> - - <!-- Optional Parameter (Third Param) --> - <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> - </methodsynopsis> - <para> - Sets options for a statement resource or a connection resource. You - cannot set options for result set resources. - </para> - </refsect1> - <refsect1 role="parameters"> - &reftitle.parameters; - <para> - <variablelist> - <varlistentry> - <term><parameter>resource</parameter></term> - <listitem> - <para> - A valid statement resource as returned from - <function>db2_prepare</function> or a valid connection resource as - returned from <function>db2_connect</function> or - <function>db2_pconnect</function>. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>options</parameter></term> - <listitem> - <para> - 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. - <variablelist> - <varlistentry> - <term><parameter>autocommit</parameter></term> - <listitem> - <para> - Passing <literal>DB2_AUTOCOMMIT_ON</literal> turns - autocommit on for the specified connection resource. - </para> - <para> - Passing <literal>DB2_AUTOCOMMIT_OFF</literal> turns - autocommit off for the specified connection resource. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>cursor</parameter></term> - <listitem> - <para> - Passing <literal>DB2_FORWARD_ONLY</literal> specifies a - forward-only cursor for a statement resource. This is the - default cursor type, and is supported by all database - servers. - </para> - <para> - Passing <literal>DB2_SCROLLABLE</literal> 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. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>binmode</parameter></term> - <listitem> - <para> - Passing <literal>DB2_BINARY</literal> specifies that - binary data will be returned as is. This is the default - mode. This is the equivalent of setting - <literal>ibm_db2.binmode=1</literal> in &php.ini;. - </para> - <para> - Passing <literal>DB2_CONVERT</literal> specifies that - binary data will be converted to hexadecimal encoding, - and will be returned as such. This is the equivalent of - setting <literal>ibm_db2.binmode=2</literal> in &php.ini;. - </para> - <para> - Passing <literal>DB2_PASSTHRU</literal> specifies that - binary data will be converted to &null;. This is the - equivalent of setting <literal>ibm_db2.binmode=3</literal> - in &php.ini;. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>db2_attr_case</parameter></term> - <listitem> - <para> - Passing <literal>DB2_CASE_LOWER</literal> specifies that - column names of the result set are returned in lower case. - </para> - <para> - Passing <literal>DB2_CASE_UPPER</literal> specifies that - column names of the result set are returned in upper case. - </para> - <para> - Passing <literal>DB2_CASE_NATURAL</literal> specifies that - column names of the result set are returned in natural - case. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>type</parameter></term> - <listitem> - <para> - An integer value that specifies the type of resource that was - passed into the function. The type of resource and this value - must correspond. - <variablelist> - <varlistentry> - <term><parameter></parameter></term> - <listitem> - <para> - Passing <literal>1</literal> as the value specifies that - a connection resource has been passed into the function. - </para> - <para> - Passing any integer not equal to <literal>1</literal> as - the value specifies that a statement resource has been - passed into the function. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - <para> - </para> - <para> - The following table specifies which options are compatible with - the available resource types: - <table> - <title>Resource-Parameter Matrix</title> - <tgroup cols="5"> - <colspec colnum="1" colname="col1" align="center" /> - <colspec colnum="2" colname="col2" align="center" /> - <colspec colnum="3" colname="col3" align="center" /> - <colspec colnum="4" colname="col4" align="center" /> - <colspec colnum="5" colname="col5" align="center" /> - - <thead> - <row> - <entry morerows="1">Key</entry> - <entry morerows="1">Value</entry> - <entry namest="col3" nameend="col5">Resource Type</entry> - </row> - </thead> - - <tbody> - <row> - <entry colname="col3">Connection</entry> - <entry colname="col4">Statement</entry> - <entry colname="col5">Result Set</entry> - </row> - <row> - <entry>autocommit</entry> - <entry><literal>DB2_AUTOCOMMIT_ON</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">-</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>autocommit</entry> - <entry><literal>DB2_AUTOCOMMIT_OFF</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">-</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>cursor</entry> - <entry><literal>DB2_SCROLLABLE</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>cursor</entry> - <entry><literal>DB2_FORWARD_ONLY</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_BINARY</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_CONVERT</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>binmode</entry> - <entry><literal>DB2_PASSTHRU</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_LOWER</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_UPPER</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - <row> - <entry>db2_attr_case</entry> - <entry><literal>DB2_CASE_NATURAL</literal></entry> - <entry colname="col3">X</entry> - <entry colname="col4">X</entry> - <entry colname="col5">-</entry> - </row> - </tbody> - </tgroup> - </table> - </para> - </refsect1> - - <refsect1 role="returnvalues"> - &reftitle.returnvalues; - <para> - &return.success; - </para> - </refsect1> - <!-- Place Changelog next if any --> - - <!-- Place Examples next if any --> - <refsect1 role="examples"> - &reftitle.examples; - <para> - - <example> - <title>Setting one parameter with a connection resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_ON); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Options Set Successfully]]></screen> - </example> - - <example> - <title>Setting multiple parameters with a connection resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Options Set Successfully]]></screen> - </example> - - <!-- Behaves Incorrectly --> - <example> - <title>Setting multiple parameters with an invalid key</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'MY_INVALID_KEY' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <!-- Behaves Incorrectly --> - <example> - <title>Setting multiple parameters with an invalid value</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => 'INVALID_VALUE', - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and type values */ -$result = db2_set_option($conn, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Setting multiple parameters with a connection resource and the wrong type</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -/* Call the function using the correct resource, options array, and the wrong type value */ -$result = db2_set_option($conn, $options, 2); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Setting multiple parameters with the wrong resource</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, - 'binmode' => DB2_PASSTHRU, - 'db2_attr_case' => DB2_CASE_UPPER, - 'cursor' => DB2_SCROLLABLE); - -$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE'); - -/* Call the function using the wrong resource, and the correct options array, and type values */ -$result = db2_set_option($stmt, $options, 1); - -/* Check if all options could be set correctly */ -if($result) -{ - echo 'Options Set Successfully'; -} -else -{ - echo 'Could Not Set Options'; -} -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Could Not Set Options]]></screen> - </example> - - <example> - <title>Putting it all together</title> - <para> - </para> - <programlisting role="php"> -<![CDATA[ -<?php -/* Database Connection Parameters */ -$database = 'SAMPLE'; -$hostname = 'localhost'; -$port = 50000; -$protocol = 'TCPIP'; -$username = 'db2inst1'; -$password = 'ibmdb2'; - -/* Connection String */ -$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; -$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; -$conn_string .= "UID=$username;PWD=$password;"; - -/* Obtain Connection Resource */ -$conn = db2_connect($conn_string, '', ''); - -/* Create the associative options array with valid key-value pairs */ -$options = array('db2_attr_case' => DB2_CASE_LOWER, - 'cursor' => DB2_SCROLLABLE); - -$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE WHERE EMPNO = ? OR EMPNO = ?'); - -/* Call the function using the correct resource, options array, and type values */ -$option_result = db2_set_option($stmt, $options, 2); -$result = db2_execute($stmt, array('000130', '000140')); - -/* Get Row 2 before Row 1 since Scrollable Cursor */ -print_r(db2_fetch_assoc($stmt, 2)); -print '<br /><br />'; -print_r(db2_fetch_assoc($stmt, 1)); - -?> -]]> - </programlisting> - &example.outputs; - <screen><![CDATA[Array -( - [empno] => 000140 - [firstnme] => HEATHER - [midinit] => A - [lastname] => NICHOLLS - [workdept] => C01 - [phoneno] => 1793 - [hiredate] => 1976-12-15 - [job] => ANALYST - [edlevel] => 18 - [sex] => F - [birthdate] => 1946-01-19 - [salary] => 28420.00 - [bonus] => 600.00 - [comm] => 2274.00 -) - -Array -( - [empno] => 000130 - [firstnme] => DELORES - [midinit] => M - [lastname] => QUINTANA - [workdept] => C01 - [phoneno] => 4578 - [hiredate] => 1971-07-28 - [job] => ANALYST - [edlevel] => 16 - [sex] => F - [birthdate] => 1925-09-15 - [salary] => 23800.00 - [bonus] => 500.00 - [comm] => 1904.00 -)]]></screen> - </example> - </para> - </refsect1> - <refsect1 role="seealso"> - &reftitle.seealso; - <para> - <simplelist> - <member><function>db2_connect</function></member> - <member><function>db2_pconnect</function></member> - <member><function>db2_exec</function></member> - <member><function>db2_prepare</function></member> - <member><function>db2_cursor_type</function></member> - </simplelist> - </para> - </refsect1> -</refentry> - -<!-- Keep this comment at the end of the file -Local variables: -mode: sgml -sgml-omittag:t -sgml-shorttag:t -sgml-minimize-attributes:nil -sgml-always-quote-attributes:t -sgml-indent-step:1 -sgml-indent-data:t -indent-tabs-mode:nil -sgml-parent-document:nil -sgml-default-dtd-file:"../../../../manual.ced" -sgml-exposed-tags:nil -sgml-local-catalogs:nil -sgml-local-ecat-files:nil -End: -vim600: syn=xml fen fdm=syntax fdl=2 si -vim: et tw=78 syn=sgml -vi: ts=1 sw=1 ---> +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- $Revision: 1.4 $ --> +<refentry id="function.db2-set-option"> + <refnamediv> + <refname>db2_set_option</refname> + <refpurpose>Set options for connection or statement resources</refpurpose> + </refnamediv> + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <!-- All Functions have this --> + <type>bool</type><methodname>db2_set_option</methodname> + + <!-- Required Parameter (First Param) --> + <methodparam><type>resource</type><parameter>resource</parameter></methodparam> + + <!-- Required Parameter (Second Param) --> + <methodparam><type>array</type><parameter>options</parameter></methodparam> + + <!-- Optional Parameter (Third Param) --> + <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> + </methodsynopsis> + <para> + Sets options for a statement resource or a connection resource. You + cannot set options for result set resources. + </para> + </refsect1> + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>resource</parameter></term> + <listitem> + <para> + A valid statement resource as returned from + <function>db2_prepare</function> or a valid connection resource as + returned from <function>db2_connect</function> or + <function>db2_pconnect</function>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>options</parameter></term> + <listitem> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>autocommit</parameter></term> + <listitem> + <para> + Passing <literal>DB2_AUTOCOMMIT_ON</literal> turns + autocommit on for the specified connection resource. + </para> + <para> + Passing <literal>DB2_AUTOCOMMIT_OFF</literal> turns + autocommit off for the specified connection resource. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>cursor</parameter></term> + <listitem> + <para> + Passing <literal>DB2_FORWARD_ONLY</literal> specifies a + forward-only cursor for a statement resource. This is the + default cursor type, and is supported by all database + servers. + </para> + <para> + Passing <literal>DB2_SCROLLABLE</literal> 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. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>binmode</parameter></term> + <listitem> + <para> + Passing <literal>DB2_BINARY</literal> specifies that + binary data will be returned as is. This is the default + mode. This is the equivalent of setting + <literal>ibm_db2.binmode=1</literal> in &php.ini;. + </para> + <para> + Passing <literal>DB2_CONVERT</literal> specifies that + binary data will be converted to hexadecimal encoding, + and will be returned as such. This is the equivalent of + setting <literal>ibm_db2.binmode=2</literal> in &php.ini;. + </para> + <para> + Passing <literal>DB2_PASSTHRU</literal> specifies that + binary data will be converted to &null;. This is the + equivalent of setting <literal>ibm_db2.binmode=3</literal> + in &php.ini;. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>db2_attr_case</parameter></term> + <listitem> + <para> + Passing <literal>DB2_CASE_LOWER</literal> specifies that + column names of the result set are returned in lower case. + </para> + <para> + Passing <literal>DB2_CASE_UPPER</literal> specifies that + column names of the result set are returned in upper case. + </para> + <para> + Passing <literal>DB2_CASE_NATURAL</literal> specifies that + column names of the result set are returned in natural + case. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + 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. + <variablelist> + <varlistentry> + <term><parameter>i5_fetch_only</parameter></term> + <listitem> + <para> + <literal>DB2_I5_FETCH_ON</literal> - Cursors are read-only + and cannot be used for positioned updates or deletes. This + is the default unless <literal>SQL_ATTR_FOR_FETCH_ONLY</literal> + environment has been set to <literal>SQL_FALSE</literal>. + </para> + <para> + <literal>DB2_I5_FETCH_OFF</literal> - Cursors can be used + for positioned updates and deletes. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>type</parameter></term> + <listitem> + <para> + An integer value that specifies the type of resource that was + passed into the function. The type of resource and this value + must correspond. + <variablelist> + <varlistentry> + <term><parameter></parameter></term> + <listitem> + <para> + Passing <literal>1</literal> as the value specifies that + a connection resource has been passed into the function. + </para> + <para> + Passing any integer not equal to <literal>1</literal> as + the value specifies that a statement resource has been + passed into the function. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + </para> + <para> + The following table specifies which options are compatible with + the available resource types: + <table> + <title>Resource-Parameter Matrix</title> + <tgroup cols="5"> + <colspec colnum="1" colname="col1" align="center" /> + <colspec colnum="2" colname="col2" align="center" /> + <colspec colnum="3" colname="col3" align="center" /> + <colspec colnum="4" colname="col4" align="center" /> + <colspec colnum="5" colname="col5" align="center" /> + + <thead> + <row> + <entry morerows="1">Key</entry> + <entry morerows="1">Value</entry> + <entry namest="col3" nameend="col5">Resource Type</entry> + </row> + </thead> + + <tbody> + <row> + <entry colname="col3">Connection</entry> + <entry colname="col4">Statement</entry> + <entry colname="col5">Result Set</entry> + </row> + <row> + <entry>autocommit</entry> + <entry><literal>DB2_AUTOCOMMIT_ON</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>autocommit</entry> + <entry><literal>DB2_AUTOCOMMIT_OFF</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>cursor</entry> + <entry><literal>DB2_SCROLLABLE</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>cursor</entry> + <entry><literal>DB2_FORWARD_ONLY</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_BINARY</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_CONVERT</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>binmode</entry> + <entry><literal>DB2_PASSTHRU</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_LOWER</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_UPPER</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>db2_attr_case</entry> + <entry><literal>DB2_CASE_NATURAL</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>i5_fetch_only</entry> + <entry><literal>DB2_I5_FETCH_ON</literal></entry> + <entry colname="col3">-</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>i5_fetch_only</entry> + <entry><literal>DB2_I5_FETCH_OFF</literal></entry> + <entry colname="col3">-</entry> + <entry colname="col4">X</entry> + <entry colname="col5">-</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + &return.success; + </para> + </refsect1> + <!-- Place Changelog next if any --> + + <!-- Place Examples next if any --> + <refsect1 role="examples"> + &reftitle.examples; + <para> + + <example> + <title>Setting one parameter with a connection resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_ON); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Options Set Successfully]]></screen> + </example> + + <example> + <title>Setting multiple parameters with a connection resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Options Set Successfully]]></screen> + </example> + + <!-- Behaves Incorrectly --> + <example> + <title>Setting multiple parameters with an invalid key</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'MY_INVALID_KEY' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <!-- Behaves Incorrectly --> + <example> + <title>Setting multiple parameters with an invalid value</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => 'INVALID_VALUE', + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and type values */ +$result = db2_set_option($conn, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Setting multiple parameters with a connection resource and the wrong type</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +/* Call the function using the correct resource, options array, and the wrong type value */ +$result = db2_set_option($conn, $options, 2); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Setting multiple parameters with the wrong resource</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('autocommit' => DB2_AUTOCOMMIT_OFF, + 'binmode' => DB2_PASSTHRU, + 'db2_attr_case' => DB2_CASE_UPPER, + 'cursor' => DB2_SCROLLABLE); + +$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE'); + +/* Call the function using the wrong resource, and the correct options array, and type values */ +$result = db2_set_option($stmt, $options, 1); + +/* Check if all options could be set correctly */ +if($result) +{ + echo 'Options Set Successfully'; +} +else +{ + echo 'Could Not Set Options'; +} +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Could Not Set Options]]></screen> + </example> + + <example> + <title>Putting it all together</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php +/* Database Connection Parameters */ +$database = 'SAMPLE'; +$hostname = 'localhost'; +$port = 50000; +$protocol = 'TCPIP'; +$username = 'db2inst1'; +$password = 'ibmdb2'; + +/* Connection String */ +$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"; +$conn_string .= "HOSTNAME=$hostname;PORT=$port;PROTOCOL=$protocol;"; +$conn_string .= "UID=$username;PWD=$password;"; + +/* Obtain Connection Resource */ +$conn = db2_connect($conn_string, '', ''); + +/* Create the associative options array with valid key-value pairs */ +$options = array('db2_attr_case' => DB2_CASE_LOWER, + 'cursor' => DB2_SCROLLABLE); + +$stmt = db2_prepare($conn, 'SELECT * FROM EMPLOYEE WHERE EMPNO = ? OR EMPNO = ?'); + +/* Call the function using the correct resource, options array, and type values */ +$option_result = db2_set_option($stmt, $options, 2); +$result = db2_execute($stmt, array('000130', '000140')); + +/* Get Row 2 before Row 1 since Scrollable Cursor */ +print_r(db2_fetch_assoc($stmt, 2)); +print '<br /><br />'; +print_r(db2_fetch_assoc($stmt, 1)); + +?> +]]> + </programlisting> + &example.outputs; + <screen><![CDATA[Array +( + [empno] => 000140 + [firstnme] => HEATHER + [midinit] => A + [lastname] => NICHOLLS + [workdept] => C01 + [phoneno] => 1793 + [hiredate] => 1976-12-15 + [job] => ANALYST + [edlevel] => 18 + [sex] => F + [birthdate] => 1946-01-19 + [salary] => 28420.00 + [bonus] => 600.00 + [comm] => 2274.00 +) + +Array +( + [empno] => 000130 + [firstnme] => DELORES + [midinit] => M + [lastname] => QUINTANA + [workdept] => C01 + [phoneno] => 4578 + [hiredate] => 1971-07-28 + [job] => ANALYST + [edlevel] => 16 + [sex] => F + [birthdate] => 1925-09-15 + [salary] => 23800.00 + [bonus] => 500.00 + [comm] => 1904.00 +)]]></screen> + </example> + <example> + <title>i5/OS cursors are read-only</title> + <para> + </para> + <programlisting role="php"> +<![CDATA[ +<?php + $conn = db2_connect("", "", "", array("i5_lib"=>"nobody")); + $stmt = db2_prepare($conn, 'select * from names where first = ?'); + $name = "first2"; + db2_bind_param($stmt, 1, "name", DB2_PARAM_IN); + $options = array("i5_fetch_only"=>DB2_I5_FETCH_ON); + db2_set_option($stmt,$options,0); + if (db2_execute($stmt)) { + while ($row = db2_fetch_array($stmt)) { + echo "{$row[0]} {$row[1]}"; + } + } +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +first2 last2 +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>db2_connect</function></member> + <member><function>db2_pconnect</function></member> + <member><function>db2_exec</function></member> + <member><function>db2_prepare</function></member> + <member><function>db2_cursor_type</function></member> + </simplelist> + </para> + </refsect1> +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +-->