PHP Manual
后退 |  | 前进

# ocibindbyname

(PHP 3 >= 3.0.4, PHP 4, PHP 5)

ocibindbyname -- °ó¶¨Ò»¸ö PHP ±äÁ¿µ½Ò»¸ö Oracle Î»ÖÃ±êÖ¾·û

## ÃèÊö

bool ocibindbyname ( resource stmt, string ph_name, mixed &variable [, int maxlength [, int type]] )

ocibindbyname() ²ÎÊý variable °ÑÒ»¸ö PHP ±äÁ¿°ó¶¨µ½ Oracle µÄÎ»ÖÃ±êÖ¾·û ph_name¡£¸Ã±äÁ¿ÊÇ·ñ»á±»ÓÃ×÷ÊäÈëÊä³öÊÇÔÚÔËÐÐÊ±¾ö¶¨µÄ£¬²¢ÇÒº¯Êý¸ø¸Ã±äÁ¿·ÖÅä±ØÒªµÄ´æ´¢¿Õ¼ä¡£ ²ÎÊý length È·¶¨¸Ã°ó¶¨µÄ×î´ó³¤¶È£¬Èç¹û½« length ÉèÎª £1£¬º¯Êý ocibindbyname() »áÓÃ¸Ã±äÁ¿µÄµ±Ç°³¤¶ÈÈ·¶¨°ó¶¨µÄ×î´ó³¤¶È¡£

Èç¹ûÄãÒª°ó¶¨Ò»¸ö³éÏóÊý¾ÝÀàÐÍ£¨LOB/ROWID/BFILE£©£¬ÄãÐèÒªÏÈÓÃ ocinewdescriptor() º¯Êý½øÐÐ¶¨Î»¡£²ÎÊý length ÔÚÕâÖÖÇé¿öÏÂ²»¿ÉÓÃ£¬Ó¦¸Ã±»ÉèÎª£1¡£ ²ÎÊý type ¸æËß Oracle ÎÒÃÇÏ£ÍûÊ¹ÓÃÊ²Ã´ÑùµÄÃèÊö·û£» ¿ÉÄÜµÄÖµÎª£º OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) ºÍ OCI_B_ROWID (ROWID)¡£

例子 1. ocibindbyname()
`<?php /* OCIBindByPos example thies at thieso dot net (980221) inserts 3 records into emp, and uses the ROWID for updating the records just after the insert. */ $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn, "insert into emp (empno, ename) " . "values (:empno,:ename) " . "returning ROWID into :rid"); $data = array(1111 => "Larry", 2222 => "Bill", 3333 => "Jim"); $rowid = OCINewDescriptor($conn, OCI_D_ROWID); OCIBindByName($stmt, ":empno", $empno, 32); OCIBindByName($stmt, ":ename", $ename, 32); OCIBindByName($stmt, ":rid", $rowid, -1, OCI_B_ROWID); $update = OCIParse($conn, "update emp set sal = :sal where ROWID = :rid"); OCIBindByName($update, ":rid", $rowid, -1, OCI_B_ROWID); OCIBindByName($update, ":sal", $sal, 32); $sal = 10000; while (list($empno, $ename) = each($data)) { OCIExecute($stmt); OCIExecute($update); } $rowid->free(); OCIFreeStatement($update); OCIFreeStatement($stmt); $stmt = OCIParse($conn, "select * from emp where empno in (1111,2222,3333)"); OCIExecute($stmt); while (OCIFetchInto($stmt, &$arr, OCI_ASSOC)) { var_dump($arr); } OCIFreeStatement($stmt); /* delete our "junk" from the emp table.... */ $stmt = OCIParse($conn, "delete from emp where empno in (1111,2222,3333)"); OCIExecute($stmt); OCIFreeStatement($stmt); OCILogoff($conn); ?>`

警告
Í¬Ê±Ê¹ÓÃÄ§ÊõÒýÓÃºÍ ocibindbyname() º¯ÊýÊÇÒ»¸ö»µÖ÷Òâ£»ÕâÊÇÒòÎª£º1¡¢±»ÒýÓÃµÄ±äÁ¿²»ÐèÒªÈÎºÎÒýÓÃ£»2¡¢ÓÉ ocibindbyname() º¯Êý²»ÄÜ·Ö±æ×Ô¶¯Ìí¼ÓµÄÒýÓÃºÍ×¨ÃÅ¼ÓÉÏµÄÒýÓÃ£¬ÕâÑùËùÓÐÄ§ÊõÓ¦ÓÃ¶¼»á±»Ð´µ½Êý¾Ý¿âÖÐ¡£

后退 | 起点 | 前进
oci_statement_type | 上一级 | ocicancel