ocidefinebyname

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

ocidefinebyname --  ÔÚÒ»¸ö SELECT ÖÐʹÓÃÒ»¸ö PHP ±äÁ¿×÷Ϊ¶¨ÒåµÄ²½Öè

ÃèÊö

bool ocidefinebyname ( resource stmt, string column_name, mixed &variable [, int type] )

ocidefinebyname() °ó¶¨ PHP µ½»ñÈ¡µÄ SQL ÁС£ ÐèҪעÒâµÄÊÇ£¬Oracle ʹÓôóд×ÖĸµÄÁÐÃû£¬¶øÔÚÄãµÄ select ÖУ¬ ÄãÒ»°ãʹÓÃСд×Öĸ¡£ ocidefinebyname() ÆÚÍû column_name ÊÇ´óд×Öĸ¡£ Èç¹ûÄãÔÚÄãµÄ select Óï¾äÖж¨ÒåÒ»¸ö²»´æÔڵıäÁ¿£¬½«Ã»ÓдíÎ󱻸ø³ö¡£

Èç¹ûÄãÐèÒª¶¨ÒåÒ»¸ö³éÏóÊý¾ÝÀàÐÍ(LOB/ROWID/BFILE)£¬ ÄãÊ×ÏÈÐèҪʹÓà ocinewdescriptor() È¥·ÖÅä¡£ ²Î¼û ocibindbyname() º¯Êý¡£

例子 1. ocidefinebyname()

<?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);
?>