I don't have cvs contribution access so if somebody could contribute this for me that would be great. I'm a newbie at this, so I hope that I've done everything correctly. Thanks!!
Summary of changes: Added the new file db2-last-insert-id.xml. (I'm attaching the file to this email. I hope that's the correct way to submit this addition.) Modified en/reference/ibm_db2/versions.xml to include entry for the new function db2_last_insert_id. Modified en/reference/ibm_db2/functions/db2-connect.xml to add trusted_context parameter and corresponding example. Modified en/reference/ibm_db2/functions/db2-pconnect to add trusted_context parameter and corresponding example. Modified en/reference/ibm_db2/functions/db2-set-option to add trusted_user and trusted_password parameters. Also fixed tagging of several notes and incorrect tagging for the type parameter. DeDe Morton
db2-last-insert-id.xml
Description: Binary data
? en/reference/ibm_db2/functions/db2-last-insert-id.xml Index: en/reference/ibm_db2/versions.xml =================================================================== RCS file: /repository/phpdoc/en/reference/ibm_db2/versions.xml,v retrieving revision 1.1 diff -u -r1.1 versions.xml --- en/reference/ibm_db2/versions.xml 28 Oct 2008 23:27:16 -0000 1.1 +++ en/reference/ibm_db2/versions.xml 8 Dec 2008 17:30:08 -0000 @@ -38,6 +38,7 @@ <function name='db2_free_stmt' from='PECL ibm_db2 >= 1.0.0'/> <function name='db2_get_option' from='PECLibm_db2 >= 1.6.0'/> <function name='db2_getoption' from='PECLibm_db2 >= 1.6.0'/> + <function name='db2_last_insert_id' from='PECLibm_db2 >= 1.7.1'/> <function name='db2_lob_read' from='PECLibm_db2 >= 1.6.0'/> <function name='db2_next_result' from='PECL ibm_db2 >= 1.0.0'/> <function name='db2_num_fields' from='PECL ibm_db2 >= 1.0.0'/> Index: en/reference/ibm_db2/functions/db2-connect.xml =================================================================== RCS file: /repository/phpdoc/en/reference/ibm_db2/functions/db2-connect.xml,v retrieving revision 1.12 diff -u -r1.12 db2-connect.xml --- en/reference/ibm_db2/functions/db2-connect.xml 20 Jun 2007 22:24:36 -0000 1.12 +++ en/reference/ibm_db2/functions/db2-connect.xml 8 Dec 2008 17:30:09 -0000 @@ -168,6 +168,36 @@ </variablelist> </para> <para> + The following new option is available as of ibm_db2 version 1.7.0. + Note: prior versions of ibm_db2 do not support this new option. + <variablelist> + <varlistentry> + <term><parameter>trustedcontext</parameter></term> + <listitem> + <para> + Passing the DB2_TRUSTED_CONTEXT_ENABLE value turns trusted context + on for this connection handle. This parameter cannot be set using + <function>db2_set_option</function>. + </para> + <para> + This key works only if the database is cataloged (even if the + database is local), or if you specify the full DSN when you create + the connection. + </para> + <para> + To catalog the database, use following commands: + </para> + <para> + <literallayout>db2 catalog tcpip node loopback remote <SERVERNAME> server <SERVICENAME> +db2 catalog database <LOCALDBNAME> as <REMOTEDBNAME> at node loopback +db2 "update dbm cfg using svcename <SERVICENAME>" +db2set DB2COMM=TCPIP</literallayout> + </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> @@ -550,6 +580,66 @@ ]]> </screen> </example> + <example> + <title>Using trusted context</title> + <para> + The following example shows how to enable trusted context, switch + users, and get the current user ID. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + +$database = "SAMPLE"; +$hostname = "localhost"; +$port = 50000; +$authID = "db2inst1"; +$auth_pass = "ibmdb2"; + +$tc_user = "tcuser"; +$tc_pass = "tcpassword"; + +$dsn = "DATABASE=$database;HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$authID;PWD=$auth_pass;"; +$options = array ("trustedcontext" => DB2_TRUSTED_CONTEXT_ENABLE); + +$tc_conn = db2_connect($dsn, "", "", $options); +if($tc_conn) { + echo "Explicit trusted connection succeeded.\n"; + + if(db2_get_option($tc_conn, "trustedcontext")) { + $userBefore = db2_get_option($tc_conn, "trusted_user"); + + //Do some work as user 1. + + //Switching to trusted user. + $parameters = array("trusted_user" => $tc_user, "trusted_password" => $tcuser_pass); + $res = db2_set_option ($tc_conn, $parameters, 1); + + $userAfter = db2_get_option($tc_conn, "trusted_user"); + //Do more work as trusted user. + + if($userBefore != $userAfter) { + echo "User has been switched." . "\n"; + } + } + + db2_close($tc_conn); +} +else { + echo "Explicit trusted connection failed.\n"; +} +?> + +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Explicit trusted connection succeeded. +User has been switched. +]]> + </screen> + </example> </para> </refsect1> Index: en/reference/ibm_db2/functions/db2-pconnect.xml =================================================================== RCS file: /repository/phpdoc/en/reference/ibm_db2/functions/db2-pconnect.xml,v retrieving revision 1.5 diff -u -r1.5 db2-pconnect.xml --- en/reference/ibm_db2/functions/db2-pconnect.xml 20 Jun 2007 22:24:36 -0000 1.5 +++ en/reference/ibm_db2/functions/db2-pconnect.xml 8 Dec 2008 17:30:09 -0000 @@ -116,6 +116,36 @@ </varlistentry> </variablelist> </para> + <para> + The following new option is available as of ibm_db2 version 1.7.0. + Note: prior versions of ibm_db2 do not support this new option. + <variablelist> + <varlistentry> + <term><parameter>trustedcontext</parameter></term> + <listitem> + <para> + Passing the DB2_TRUSTED_CONTEXT_ENABLE value turns trusted context + on for this connection handle. This parameter cannot be set using + <function>db2_set_option</function>. + </para> + <para> + This key works only if the database is cataloged (even if the + database is local), or if you specify the full DSN when you create + the connection. + </para> + <para> + To catalog the database, use following commands: + </para> + <para> + <literallayout>db2 catalog tcpip node loopback remote <SERVERNAME> server <SERVICENAME> +db2 catalog database <LOCALDBNAME> as <REMOTEDBNAME> at node loopback +db2 "update dbm cfg using svcename <SERVICENAME>" +db2set DB2COMM=TCPIP</literallayout> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> </listitem> </varlistentry> </variablelist> @@ -179,6 +209,66 @@ ]]> </screen> </example> + <example> + <title>Using trusted context</title> + <para> + The following example shows how to enable trusted context, switch + users, and get the current user ID. + </para> + <programlisting role="php"> +<![CDATA[ +<?php + +$database = "SAMPLE"; +$hostname = "localhost"; +$port = 50000; +$authID = "db2inst1"; +$auth_pass = "ibmdb2"; + +$tc_user = "tcuser"; +$tc_pass = "tcpassword"; + +$dsn = "DATABASE=$database;HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$authID;PWD=$auth_pass;"; +$options = array ("trustedcontext" => DB2_TRUSTED_CONTEXT_ENABLE); + +$tc_conn = db2_pconnect($dsn, "", "", $options); +if($tc_conn) { + echo "Explicit trusted connection succeeded.\n"; + + if(db2_get_option($tc_conn, "trustedcontext")) { + $userBefore = db2_get_option($tc_conn, "trusted_user"); + + //Do some work as user 1. + + //Switching to trusted user. + $parameters = array("trusted_user" => $tc_user, "trusted_password" => $tcuser_pass); + $res = db2_set_option ($tc_conn, $parameters, 1); + + $userAfter = db2_get_option($tc_conn, "trusted_user"); + //Do more work as trusted user. + + if($userBefore != $userAfter) { + echo "User has been switched." . "\n"; + } + } + + db2_close($tc_conn); +} +else { + echo "Explicit trusted connection failed.\n"; +} +?> + +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Explicit trusted connection succeeded. +User has been switched. +]]> + </screen> + </example> </para> </refsect1> Index: en/reference/ibm_db2/functions/db2-set-option.xml =================================================================== RCS file: /repository/phpdoc/en/reference/ibm_db2/functions/db2-set-option.xml,v retrieving revision 1.8 diff -u -r1.8 db2-set-option.xml --- en/reference/ibm_db2/functions/db2-set-option.xml 1 Nov 2007 16:40:38 -0000 1.8 +++ en/reference/ibm_db2/functions/db2-set-option.xml 8 Dec 2008 17:30:10 -0000 @@ -133,7 +133,6 @@ <para> The following new i5/OS options are available as of ibm_db2 version 1.5.1. <note> - <title>Note</title> <para> Prior versions of ibm_db2 do not support these new i5 options. </para> @@ -157,10 +156,39 @@ </variablelist> </para> <para> + The following new options are available as of ibm_db2 version 1.7.0. + <note> + <para> + Prior versions of ibm_db2 do not support these new options. + </para> + </note> + <variablelist> + <varlistentry> + <term><parameter>trusted_user</parameter></term> + <listitem> + <para> + To switch the user to a trusted user, pass the User ID (String) + of the trusted user as the value of this key. This option can + be set on a connection resource only. To use this option, trusted + context must be enabled on the connection resource. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>trusted_password</parameter></term> + <listitem> + <para> + The password (String) that corresponds to the user specified + by the trusted_user key. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> The following new options are available as of ibm_db2 version 1.6.0. They provide useful tracking information that can be accessed during execution with <function>db2_get_option</function>. <note> - <title>Note</title> <para> Prior versions of ibm_db2 do not support these new options. </para> @@ -183,7 +211,6 @@ character string used to identify the client user ID sent to the host database server when using DB2 Connect. <note> - <title>Note</title> <para> DB2 for z/OS and OS/390 servers support up to a length of 16 characters. This user-id is not to be confused with the authentication user-id, it is for @@ -201,7 +228,6 @@ character string used to identify the client accounting string sent to the host database server when using DB2 Connect. <note> - <title>Note</title> <para> DB2 for z/OS and OS/390 servers support up to a length of 200 characters. </para> @@ -217,7 +243,6 @@ character string used to identify the client application name sent to the host database server when using DB2 Connect. <note> - <title>Note</title> <para> DB2 for z/OS and OS/390 servers support up to a length of 32 characters. </para> @@ -233,7 +258,6 @@ character string used to identify the client workstation name sent to the host database server when using DB2 Connect. <note> - <title>Note</title> <para> DB2 for z/OS and OS/390 servers support up to a length of 18 characters. </para> @@ -252,22 +276,15 @@ 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> + <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> @@ -400,6 +417,20 @@ <entry colname="col5">-</entry> </row> <row> + <entry>trusted_user</entry> + <entry><literal><USER NAME> (String)</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> + <entry>trusted_password</entry> + <entry><literal><PASSWORD> (String)</literal></entry> + <entry colname="col3">X</entry> + <entry colname="col4">-</entry> + <entry colname="col5">-</entry> + </row> + <row> <entry>userid</entry> <entry><literal>SQL_ATTR_INFO_USERID</literal></entry> <entry colname="col3">X</entry>