cvs: phpdoc-zh /reference/oci8/functions ocibindbyname.xml ocidefinebyname.xml ocierror.xml ocifetchstatement.xml ocilogon.xml ocinewcursor.xml
ocinewdescriptor.xml ocinlogon.xml ocinumcols.xml ociplogon.xml

From: Date: Sun, 11 Jan 2004 10:41:51 +0000
Subject: cvs: phpdoc-zh /reference/oci8/functions ocibindbyname.xml ocidefinebyname.xml ocierror.xml ocifetchstatement.xml ocilogon.xml ocinewcursor.xml
ocinewdescriptor.xml ocinlogon.xml ocinumcols.xml ociplogon.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-1839@lists.php.net to get a copy of this message
yincheng Sun Jan 11 05:41:51 2004 EDT Added files: /phpdoc-zh/reference/oci8/functions ocidefinebyname.xml ocierror.xml ocifetchstatement.xml ocilogon.xml ocinewcursor.xml ocinewdescriptor.xml ocinlogon.xml ocinumcols.xml ociplogon.xml Modified files: /phpdoc-zh/reference/oci8/functions ocibindbyname.xml Log: add

Index: phpdoc-zh/reference/oci8/functions/ocibindbyname.xml diff -u phpdoc-zh/reference/oci8/functions/ocibindbyname.xml:1.7 phpdoc-zh/reference/oci8/functions/ocibindbyname.xml:1.8 --- phpdoc-zh/reference/oci8/functions/ocibindbyname.xml:1.7 Sat Jan 3 05:43:16 2004 +++ phpdoc-zh/reference/oci8/functions/ocibindbyname.xml Sun Jan 11 05:41:51 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.11 Maintainer: yincheng Status: ready --> <!-- CREDITS: xuke, Gregory --> @@ -30,7 +30,7 @@ <para> Èç¹ûÄãÒª°ó¶¨Ò»¸ö³éÏóÊý¾ÝÀàÐÍ£¨LOB/ROWID/BFILE£©£¬ÄãÐèÒªÏÈÓà <function>ocinewdescriptor</function> º¯Êý½øÐж¨Î»¡£²ÎÊý length ÔÚÕâÖÖÇé¿öϲ»¿ÉÓã¬Ó¦¸Ã±»ÉèΪ£­1¡£ ²ÎÊý type ¸æËß Oracle ÎÒÃÇÏ£ÍûʹÓÃʲôÑùµÄÃèÊö·û£» ¿ÉÄܵÄֵΪ£º OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB - (Binary-LOB) and OCI_B_ROWID (ROWID)¡£ + (Binary-LOB) ºÍ OCI_B_ROWID (ROWID)¡£ </para> <para> <example> Index: phpdoc-zh/reference/oci8/functions/ocidefinebyname.xml +++ phpdoc-zh/reference/oci8/functions/ocidefinebyname.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.9 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocidefinebyname"> <refnamediv> <refname>ocidefinebyname</refname> <refpurpose> ÔÚÒ»¸ö SELECT ÖÐʹÓÃÒ»¸ö PHP ±äÁ¿×÷Ϊ¶¨ÒåµÄ²½Öè </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>bool</type><methodname>ocidefinebyname</methodname> <methodparam><type>resource</type><parameter>stmt</parameter></methodparam> <methodparam><type>string</type><parameter>column_name</parameter></methodparam> <methodparam><type>mixed</type><parameter>&amp;variable</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> </methodsynopsis> <para> <function>ocidefinebyname</function> °ó¶¨ PHP µ½»ñÈ¡µÄ SQL ÁС£ ÐèҪעÒâµÄÊÇ£¬Oracle ʹÓôóд×ÖĸµÄÁÐÃû£¬¶øÔÚÄãµÄ select ÖУ¬ ÄãÒ»°ãʹÓÃСд×Öĸ¡£ <function>ocidefinebyname</function> ÆÚÍû <parameter>column_name</parameter> ÊÇ´óд×Öĸ¡£ Èç¹ûÄãÔÚÄãµÄ select Óï¾äÖж¨ÒåÒ»¸ö²»´æÔڵıäÁ¿£¬½«Ã»ÓдíÎ󱻸ø³ö¡£ </para> <para> Èç¹ûÄãÐèÒª¶¨ÒåÒ»¸ö³éÏóÊý¾ÝÀàÐÍ(LOB/ROWID/BFILE)£¬ ÄãÊ×ÏÈÐèҪʹÓà <function>ocinewdescriptor</function> È¥·ÖÅä¡£ ²Î¼û <function>ocibindbyname</function> º¯Êý¡£ </para> <example> <title><function>ocidefinebyname</function></title> <programlisting role="php"> <![CDATA[ <?php /* OCIDefineByName example - thies at thieso dot net (980219) */ $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn, "select empno, ename from emp"); /* the define MUST be done BEFORE ociexecute! */ OCIDefineByName($stmt, "EMPNO", $empno); OCIDefineByName($stmt, "ENAME", $ename); OCIExecute($stmt); while (OCIFetch($stmt)) { echo "empno:" . $empno . "\n"; echo "ename:" . $ename . "\n"; } OCIFreeStatement($stmt); OCILogoff($conn); ?> ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocierror.xml +++ phpdoc-zh/reference/oci8/functions/ocierror.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.7 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocierror"> <refnamediv> <refname>ocierror</refname> <refpurpose>·µ»Ø stmt|conn|global µÄ×îºóµÄ´íÎó</refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>array</type><methodname>ocierror</methodname> <methodparam choice="opt"><type>resource</type><parameter>stmt|conn|global</parameter></methodparam> </methodsynopsis> <simpara> <function>ocierror</function> ·µ»ØËü·¢ÏÖµÄ×îºóµÄ´íÎó¡£ Èç¹û¿ÉÑ¡²ÎÊý <parameter>stmt|conn|global</parameter> ûÓÐÌṩ£¬ º¯Êý·µ»ØËüÓöµ½µÄ×îºóµÄ´íÎó¡£Èç¹ûûÓдíÎó·¢ÏÖ£¬ <function>ocierror</function> ·µ»Ø &false;.¡£<function>ocierror</function> ÓÃÒ»¸öÏà¹ØµÄÊý×é·µ»Ø´íÎó¡£ ÔÚÕâ¸öÊý×éÖУ¬<literal>code</literal> ÊÇ oracle ´íÎó´úÂ룬 <literal>message</literal> ÊÇ oracle µÄ´íÎó×Ö·û´®¡£ </simpara> <note> <title>ÔÚ PHP 4.3 ÖÐ</title> <simpara> <literal>offset</literal> ºÍ <literal>sqltext</literal> Ò²°üÀ¨ÔÚ·µ»ØµÄÊý×éÖУ¬ ÓÃÀ´Ö¸³ö´íÎó·¢ÉúµÄλÖÃÒÔ¼°Ôì³É´íÎóµÄԭʼµÄ SQL Îı¾¡£ </simpara> </note> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocifetchstatement.xml +++ phpdoc-zh/reference/oci8/functions/ocifetchstatement.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.10 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocifetchstatement"> <refnamediv> <refname>ocifetchstatement</refname> <refpurpose>»ñÈ¡½á¹ûÊý¾ÝµÄËùÓÐÐе½Ò»¸öÊý×é</refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>int</type><methodname>ocifetchstatement</methodname> <methodparam><type>resource</type><parameter>stmt</parameter></methodparam> <methodparam><type>array</type><parameter>&amp;output</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>skip</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>maxrows</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> <function>ocifetchstatement</function> ´ÓÒ»¸ö½á¹ûÖлñÈ¡ËùÓеÄÐе½Ò»¸ö Óû§¶¨ÒåµÄÊý×é¡£ <function>ocifetchstatement</function> ·µ»Ø»ñÈ¡µÄÐÐÊý¡£ <parameter>skip</parameter> ÊÇ´Ó½á¹ûÖлñÈ¡Êý¾Ýʱ£¬×ʼºöÂÔµÄÐÐÊý (¸Ã²ÎÊýµÄĬÈÏÖµÊÇ 0£¬¼´´ÓµÚÒ»ÐпªÊ¼)¡£ <parameter>maxrows</parameter> ÊǶÁÈ¡µÄÐÐÊý£¬´ÓµÚ <parameter>skip</parameter> ÐпªÊ¼ (ĬÈÏÖµÊÇ -1£¬¼´ËùÓÐÐÐ)¡£ </para> <para> <parameter>flags</parameter> ±íʾ´æÔÚµÄÑ¡Ï ¿ÉÒÔÊÇÏÂÁÐÈÎÒ»µÄ×éºÏ£º <simplelist> <member> <constant>OCI_FETCHSTATEMENT_BY_ROW</constant> </member> <member> <constant>OCI_FETCHSTATEMENT_BY_COLUMN</constant> (ĬÈÏÖµ) </member> <member> <constant>OCI_NUM</constant> </member> <member> <constant>OCI_ASSOC</constant> </member> </simplelist> </para> <para> <example> <title><function>ocifetchstatement</function></title> <programlisting role="php"> <![CDATA[ <?php /* OCIFetchStatement example mbritton at verinet dot com (990624) */ $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn, "select * from emp"); OCIExecute($stmt); $nrows = OCIFetchStatement($stmt, $results); if ($nrows > 0) { echo "<table border=\"1\">\n"; echo "<tr>\n"; while (list($key, $val) = each($results)) { echo "<th>$key</th>\n"; } echo "</tr>\n"; for ($i = 0; $i < $nrows; $i++) { reset($results); echo "<tr>\n"; while ($column = each($results)) { $data = $column['value']; echo "<td>$data[$i]</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; } else { echo "No data found<br />\n"; } echo "$nrows Records Selected<br />\n"; OCIFreeStatement($stmt); OCILogoff($conn); ?> ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocilogon.xml +++ phpdoc-zh/reference/oci8/functions/ocilogon.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.8 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocilogon"> <refnamediv> <refname>ocilogon</refname> <refpurpose>È·Á¢Ò»¸öµ½ Oracle µÄÁ¬½Ó</refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>resource</type><methodname>ocilogon</methodname> <methodparam><type>string</type><parameter>username</parameter></methodparam> <methodparam><type>string</type><parameter>password</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> <function>ocilogon</function> ·µ»ØÒ»¸öOCI µ÷ÓÃÐèÒªµÄÁ¬½Ó±êÖ¾·û¡£ ¿ÉÑ¡µÄµÚ3¸ö²ÎÊýº¬ÓÐÄãÏëÒªÁ¬½ÓµÄÊý¾Ý¿âµÄÃû×Ö£¬¸ÃÃû×ÖΪ±¾µØ Oracle ʵÁеÄÃû×Ö»òÕßÔÚ tnsnames.ora µÄÌõÄ¿ÖеÄÃû×Ö¡£ Èç¹ûµÚ3¸ö²ÎÊýûÓж¨Ò壬 PHP ʹÓû·¾³±äÁ¿ ORACLE_SID (Oracle ʵÁÐ) »ò TWO_TASK (tnsnames.ora) À´È·¶¨Á¬½ÓÄÄÒ»¸öÊý¾Ý¿â¡£ </para> <para>µ±Ê¹Óà <function>ocilogon</function> µÄʱºò£¬ Á¬½ÓÔÚҳˮƽÉϱ»¹²Ïí¡£ ÕâÒâζ×ÅÌá½»ºÍ»Ø¹öÓ¦Óõ½¸ÃÒ³ËùÓпª·ÅµÄÊÂÎñ£¬ÉõÖÁÔÚÄãÒѾ­´´½¨ ¶à¸öÁ¬½ÓµÄÇé¿öÏ¡£ </para> <para> Õâ¸öÀý×ÓÑÝʾÁ¬½ÓÊÇÔõÑù±»¹²ÏíµÄ¡£ <example> <title><function>ocilogon</function></title> <programlisting role="php"> <![CDATA[ <?php echo "<pre>"; $db = ""; $c1 = ocilogon("scott", "tiger", $db); $c2 = ocilogon("scott", "tiger", $db); function create_table($conn) { $stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))"); ociexecute($stmt); echo $conn . " created table\n\n"; } function drop_table($conn) { $stmt = ociparse($conn, "drop table scott.hallo"); ociexecute($stmt); echo $conn . " dropped table\n\n"; } function insert_data($conn) { $stmt = ociparse($conn, "insert into scott.hallo values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))"); ociexecute($stmt, OCI_DEFAULT); echo $conn . " inserted hallo\n\n"; } function delete_data($conn) { $stmt = ociparse($conn, "delete from scott.hallo"); ociexecute($stmt, OCI_DEFAULT); echo $conn . " deleted hallo\n\n"; } function commit($conn) { ocicommit($conn); echo $conn . " committed\n\n"; } function rollback($conn) { ocirollback($conn); echo $conn . " rollback\n\n"; } function select_data($conn) { $stmt = ociparse($conn, "select * from scott.hallo"); ociexecute($stmt, OCI_DEFAULT); echo $conn."----selecting\n\n"; while (ocifetch($stmt)) { echo $conn . " [" . ociresult($stmt, "TEST") . "]\n\n"; } echo $conn . "----done\n\n"; } create_table($c1); insert_data($c1); // Insert a row using c1 insert_data($c2); // Insert a row using c2 select_data($c1); // Results of both inserts are returned select_data($c2); rollback($c1); // Rollback using c1 select_data($c1); // Both inserts have been rolled back select_data($c2); insert_data($c2); // Insert a row using c2 commit($c2); // Commit using c2 select_data($c1); // Result of c2 insert is returned delete_data($c1); // Delete all rows in table using c1 select_data($c1); // No rows returned select_data($c2); // No rows returned commit($c1); // Commit using c1 select_data($c1); // No rows returned select_data($c2); // No rows returned drop_table($c1); echo "</pre>"; ?> ]]> </programlisting> </example> </para> <simpara> ²Î¼û <function>ociplogon</function> ºÍ <function>ocinlogon</function>¡£</simpara> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocinewcursor.xml +++ phpdoc-zh/reference/oci8/functions/ocinewcursor.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.6 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocinewcursor"> <refnamediv> <refname>ocinewcursor</refname> <refpurpose> ·µ»ØÒ»¸öеÄÓαê(Óï¾ä¾ä±ú) </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>resource</type><methodname>ocinewcursor</methodname> <methodparam><type>resource</type><parameter>conn</parameter></methodparam> </methodsynopsis> <para> <function>ocinewcursor</function> ÔÚÌØ¶¨µÄÁ¬½ÓÉÏ·ÖÅäÒ»¸öеÄÓï¾ä¾ä±ú¡£ </para> <para> <example> <title>´ÓÒ»¸ö Oracle µÄ´¢´æ¹ý³ÌÖÐʹÓÃÒ»¸ö REF CURSOR</title> <programlisting role="php"> <![CDATA[ <?php // suppose your stored procedure info.output returns a ref cursor in :data $conn = OCILogon("scott", "tiger"); $curs = OCINewCursor($conn); $stmt = OCIParse($conn, "begin info.output(:data); end;"); ocibindbyname($stmt, "data", &$curs, -1, OCI_B_CURSOR); ociexecute($stmt); ociexecute($curs); while (OCIFetchInto($curs, &$data)) { var_dump($data); } OCIFreeStatement($stmt); OCIFreeCursor($curs); OCILogoff($conn); ?> ]]> </programlisting> </example> </para> <para> <example> <title>ÔÚ Oracle µÄ select Óï¾äÖÐʹÓà REF CURSOR</title> <programlisting role="php"> <![CDATA[ <?php echo "<html><body>"; $conn = OCILogon("scott", "tiger"); $count_cursor = "CURSOR(select count(empno) num_emps from emp " . "where emp.deptno = dept.deptno) as EMPCNT from dept"; $stmt = OCIParse($conn, "select deptno,dname,$count_cursor"); ociexecute($stmt); echo "<table border=\"1\">"; echo "<tr>"; echo "<th>DEPT NAME</th>"; echo "<th>DEPT #</th>"; echo "<th># EMPLOYEES</th>"; echo "</tr>"; while (OCIFetchInto($stmt, &$data, OCI_ASSOC)) { echo "<tr>"; $dname = $data["DNAME"]; $deptno = $data["DEPTNO"]; echo "<td>$dname</td>"; echo "<td>$deptno</td>"; ociexecute($data["EMPCNT"]); while (OCIFetchInto($data["EMPCNT"], &$subdata, OCI_ASSOC)) { $num_emps = $subdata["NUM_EMPS"]; echo "<td>$num_emps</td>"; } echo "</tr>"; } echo "</table>"; echo "</body></html>"; OCIFreeStatement($stmt); OCILogoff($conn); ?> ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocinewdescriptor.xml +++ phpdoc-zh/reference/oci8/functions/ocinewdescriptor.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.9 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocinewdescriptor"> <refnamediv> <refname>ocinewdescriptor</refname> <refpurpose> ³õʼ»¯Ò»¸öÐÂµÄ¿Õ LOB »ò FILE ÃèÊö·û </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>object</type><methodname>ocinewdescriptor</methodname> <methodparam><type>resource</type><parameter>connection</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> </methodsynopsis> <para> <function>ocinewdescriptor</function> ·ÖÅä¿Õ¼ä´æ´¢ÃèÊö·û»ò LOB ¶¨Î»Æ÷¡£ ÓÐЧµÄ <parameter>type</parameter> ÖµÊÇ <constant>OCI_D_FILE</constant>¡¢ <constant>OCI_D_LOB</constant> ºÍ <constant>OCI_D_ROWID</constant>¡£ ¶ÔÓÚ LOB ÃèÊö·û£¬·½·¨ load, save, ºÍ savefile ÓëÃèÊö·ûÏà¹Ø£¬¶ø BFILE Ö»´æÔÚ load ·½·¨¡£²Î¼ûµÚ¶þ¸öÀý×ÓµÄʹÓÃÌáʾ¡£ </para> <para> <example> <title><function>ocinewdescriptor</function></title> <programlisting role="php"> <![CDATA[ <?php /* This script is designed to be called from a HTML form. * It expects $user, $password, $table, $where, and $commitsize * to be passed in from the form. The script then deletes * the selected rows using the ROWID and commits after each * set of $commitsize rows. (Use with care, there is no rollback) */ $conn = OCILogon($user, $password); $stmt = OCIParse($conn, "select rowid from $table $where"); $rowid = OCINewDescriptor($conn, OCI_D_ROWID); OCIDefineByName($stmt, "ROWID", &$rowid); OCIExecute($stmt); while (OCIFetch($stmt)) { $nrows = OCIRowCount($stmt); $delete = OCIParse($conn, "delete from $table where ROWID = :rid"); OCIBindByName($delete, ":rid", &$rowid, -1, OCI_B_ROWID); OCIExecute($delete); echo "$nrows\n"; if (($nrows % $commitsize) == 0) { OCICommit($conn); } } $nrows = OCIRowCount($stmt); echo "$nrows deleted...\n"; OCIFreeStatement($stmt); OCILogoff($conn); ?> ]]> </programlisting> <programlisting role="php"> <![CDATA[ <?php /* This script demonstrates file upload to LOB columns * The formfield used for this example looks like this * <form action="upload.php" method="post" enctype="multipart/form-data"> * <input type="file" name="lob_upload" /> * ... */ if (!isset($lob_upload) || $lob_upload == 'none'){ ?> <form action="upload.php" method="post" enctype="multipart/form-data"> Upload file: <input type="file" name="lob_upload" /><br /> <input type="submit" value="Upload" /> - <input type="reset" value="Reset" /> </form> <?php } else { // $lob_upload contains the temporary filename of the uploaded file // see also the features section on file upload, // if you would like to use secure uploads $conn = OCILogon($user, $password); $lob = OCINewDescriptor($conn, OCI_D_LOB); $stmt = OCIParse($conn, "insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); OCIExecute($stmt, OCI_DEFAULT); if ($lob->savefile($lob_upload)){ OCICommit($conn); echo "Blob successfully uploaded\n"; }else{ echo "Couldn't upload Blob\n"; } OCIFreeDesc($lob); OCIFreeStatement($stmt); OCILogoff($conn); } ?> ]]> </programlisting> </example> <example> <title><function>ocinewdescriptor</function></title> <programlisting role="php"> <![CDATA[ <?php /* Calling PL/SQL stored procedures which contain clobs as input * parameters (PHP 4 >= 4.0.6). * Example PL/SQL stored procedure signature is: * * PROCEDURE save_data * Argument Name Type In/Out Default? * ------------------------------ ----------------------- ------ -------- * KEY NUMBER(38) IN * DATA CLOB IN * */ $conn = OCILogon($user, $password); $stmt = OCIParse($conn, "begin save_data(:key, :data); end;"); $clob = OCINewDescriptor($conn, OCI_D_LOB); OCIBindByName($stmt, ':key', $key); OCIBindByName($stmt, ':data', $clob, -1, OCI_B_CLOB); $clob->WriteTemporary($data); OCIExecute($stmt, OCI_DEFAULT); OCICommit($conn); $clob->close(); $clob->free(); OCIFreeStatement($stmt); ?> ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocinlogon.xml +++ phpdoc-zh/reference/oci8/functions/ocinlogon.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.7 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.15 --> <refentry id="function.ocinlogon"> <refnamediv> <refname>ocinlogon</refname> <refpurpose>È·¶¨Ò»¸öµ½ Oracle µÄÐÂÁ¬½Ó</refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>resource</type><methodname>ocinlogon</methodname> <methodparam><type>string</type><parameter>username</parameter></methodparam> <methodparam><type>string</type><parameter>password</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> <function>ocinlogon</function> ´´½¨Ò»¸öµ½Oracle 8 Êý¾Ý¿âµÄÐÂÁ¬½Ó¡£ ¿ÉÑ¡µÄµÚ3¸ö²ÎÊýº¬ÓÐÄãÏëÒªÁ¬½ÓµÄÊý¾Ý¿âµÄÃû×Ö£¬¸ÃÃû×ÖΪ±¾µØ Oracle ʵÁеÄÃû×Ö»òÕßÔÚ tnsnames.ora µÄÌõÄ¿ÖеÄÃû×Ö¡£ Èç¹ûµÚ3¸ö²ÎÊýûÓж¨Ò壬 PHP ʹÓû·¾³±äÁ¿ ORACLE_SID (Oracle ʵÁÐ) »ò TWO_TASK (tnsnames.ora) À´È·¶¨Á¬½ÓÄÄÒ»¸öÊý¾Ý¿â¡£ </para> <para> <function>ocinlogon</function> Ç¿ÆÈ´ò¿ªÒ»¸öеÄÁ¬½Ó¡£ Èç¹ûÄãÐèÒª¸ôÀëһϵÁÐÊÂÎñʱ£¬¸Ãº¯Êý½«±»Óõ½¡£ ÔÚĬÈϵÄÇé¿öÏ£¬Èç¹ûʹÓà <function>ocilogon</function>£¬Á¬½Ó½« ÔÚҳˮƽ±»¹²Ïí£»Èç¹ûʹÓà <function>ociplogon</function>£¬Á¬½Ó½« ±»ÔÚ web ·þÎñÆ÷½ø³Ìˮƽ±»¹²Ïí¡£Èç¹ûÄãÓÐʹÓà <function>ocinlogon</function> ´ò¿ªµÄÁ¬½Ó£¬ËùÓеÄÌá½»ºÍ»Ø¹ö½ö½öÓ¦Óõ½Ìض¨µÄÁ¬½Ó¡£ </para> <para> ÏÂÃæµÄÀý×ÓÁ¬½ÓÊÇÔõô±»¸ôÀëµÄ¡£ <example> <title><function>ocinlogon</function></title> <programlisting role="php"> <![CDATA[ <?php echo "<html><pre>"; $db = ""; $c1 = ocilogon("scott", "tiger", $db); $c2 = ocinlogon("scott", "tiger", $db); function create_table($conn) { $stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))"); ociexecute($stmt); echo $conn . " created table\n\n"; } function drop_table($conn) { $stmt = ociparse($conn, "drop table scott.hallo"); ociexecute($stmt); echo $conn . " dropped table\n\n"; } function insert_data($conn) { $stmt = ociparse($conn, "insert into scott.hallo values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))"); ociexecute($stmt, OCI_DEFAULT); echo $conn . " inserted hallo\n\n"; } function delete_data($conn) { $stmt = ociparse($conn, "delete from scott.hallo"); ociexecute($stmt, OCI_DEFAULT); echo $conn . " deleted hallo\n\n"; } function commit($conn) { ocicommit($conn); echo $conn . " committed\n\n"; } function rollback($conn) { ocirollback($conn); echo $conn . " rollback\n\n"; } function select_data($conn) { $stmt = ociparse($conn, "select * from scott.hallo"); ociexecute($stmt, OCI_DEFAULT); echo $conn . "----selecting\n\n"; while (ocifetch($stmt)) { echo $conn . " <" . ociresult($stmt, "TEST") . ">\n\n"; } echo $conn . "----done\n\n"; } create_table($c1); insert_data($c1); select_data($c1); select_data($c2); rollback($c1); select_data($c1); select_data($c2); insert_data($c2); commit($c2); select_data($c1); delete_data($c1); select_data($c1); select_data($c2); commit($c1); select_data($c1); select_data($c2); drop_table($c1); echo "</pre></html>"; ?> ]]> </programlisting> </example> </para> <simpara> ²Î¼û <function>ocilogon</function> ºÍ <function>ociplogon</function>¡£ </simpara> </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 --> Index: phpdoc-zh/reference/oci8/functions/ocinumcols.xml +++ phpdoc-zh/reference/oci8/functions/ocinumcols.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.7 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 --> <refentry id="function.ocinumcols"> <refnamediv> <refname>ocinumcols</refname> <refpurpose> ·µ»ØÁÐÊý </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>int</type><methodname>ocinumcols</methodname> <methodparam><type>resource</type><parameter>stmt</parameter></methodparam> </methodsynopsis> <para> <function>ocinumcols</function> ·µ»ØÔÚÓï¾ä <parameter>stmt</parameter> ÖеÄÁÐÊý¡£ </para> <para> <example> <title><function>ocinumcols</function></title> <programlisting role="php"> <![CDATA[ <?php echo "<pre>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn, "select * from emp"); OCIExecute($stmt); while (OCIFetch($stmt)) { echo "\n"; $ncols = OCINumCols($stmt); for ($i = 1; $i <= $ncols; $i++) { $column_name = OCIColumnName($stmt, $i); $column_value = OCIResult($stmt, $i); echo $column_name . ': ' . $column_value . "\n"; } echo "\n"; } OCIFreeStatement($stmt); OCILogoff($conn); echo "</pre>"; ?> ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/oci8/functions/ociplogon.xml +++ phpdoc-zh/reference/oci8/functions/ociplogon.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.4 Maintainer: yincheng Status: ready --> <!-- splitted from ./en/functions/oci8.xml, last change in rev 1.15 --> <refentry id="function.ociplogon"> <refnamediv> <refname>ociplogon</refname> <refpurpose> ʹÓÃÒ»¸ö³ÖÐøÐÔÁ¬½ÓÁ¬µ½ Oracle Êý¾Ý¿â </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>resource</type><methodname>ociplogon</methodname> <methodparam><type>string</type><parameter>username</parameter></methodparam> <methodparam><type>string</type><parameter>password</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>db</parameter></methodparam> </methodsynopsis> <para> <function>ociplogon</function> ´´½¨Ò»¸öµ½ Oracle 8 Êý¾Ý¿âµÄ³ÖÐøÐÔÁ¬½Ó¡£ ¿ÉÑ¡µÄµÚ3¸ö²ÎÊýº¬ÓÐÄãÏëÒªÁ¬½ÓµÄÊý¾Ý¿âµÄÃû×Ö£¬¸ÃÃû×ÖΪ±¾µØ Oracle ʵÁеÄÃû×Ö»òÕßÔÚ tnsnames.ora µÄÌõÄ¿ÖеÄÃû×Ö¡£ Èç¹ûµÚ3¸ö²ÎÊýûÓж¨Ò壬 PHP ʹÓû·¾³±äÁ¿ ORACLE_SID (Oracle ʵÁÐ) »ò TWO_TASK (tnsnames.ora) À´È·¶¨Á¬½ÓÄÄÒ»¸öÊý¾Ý¿â¡£ </para> <simpara> ²Î¼û <function>ocilogon</function> ºÍ <function>ocinlogon</function>¡£ </simpara> </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 -->
« previous php.doc.zh (#1839) next »