PHP Manual
后退 |  | 前进

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

后退 | 起点 | 前进
ocicommit | 上一级 | ocierror