oci_result

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

oci_result返回所取得行中字段的值

说明

oci_result(resource $statement, string|int $column): mixed

返回由 oci_fetch() 所读取的当前行中 column 的数据。

要获取 OCI8 扩展进行数据类型映射的细节,请参见驱动所支持的数据类型

参数

statement

column

可以使用列号(从 1 开始)或列名。列名的大小写必须是 Oracle 元数据描述该列的大小写,对于创建的不区分大小写的列来说是大写。

返回值

以字符串形式返回除抽象类型(ROWID、LOB 和 FILE)之外的所有内容。在出错时返回 false

范例

示例 #1 oci_fetch()oci_result()

<?php

$conn
= oci_connect('hr', 'welcome', 'localhost/XE');
if (!
$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

$sql = 'SELECT location_id, city FROM locations WHERE location_id < 1200';
$stid = oci_parse($conn, $sql);
oci_execute($stid);

while (
oci_fetch($stid)) {
echo
oci_result($stid, 'LOCATION_ID') . " is ";
echo
oci_result($stid, 'CITY') . "<br>\n";
}

// Displays:
// 1000 is Roma
// 1100 is Venice

oci_free_statement($stid);
oci_close($conn);

?>

注释

注意:

在 PHP 5.0.0 之前的版本必须使用 ociresult() 替代本函数。该函数名仍然可用,为向下兼容作为 oci_result() 的别名。不过其已被废弃,不推荐使用。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top