aci_fetch

aci_fetch—将下一行提取到结果缓冲区

说明

aci_fetch(resource $statement): bool

aci_fetch() 获取下一行(对于 SELECT 语句)到内部结果缓冲区。

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

参数

statement

有效的 ACI8 报表标识符 由 aci_parse() 创建,被 aci_execute() 或 REF CURSOR statement 标识执行。

范例

示例 #1 具有定义变量的aci_fetch()

<?php

$conn =aci_connect('sysdba', 'szoscar55', 'localhost:2003/OSRDB');
if (!$conn) {
        $e = aci_error();
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

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

// The defines MUST be done before executing
aci_define_by_name($stid, 'LOCATION_ID', $locid);
aci_define_by_name($stid, 'CITY', $city);

aci_execute($stid);

// Each fetch populates the previously defined variables with the next row's data
while (aci_fetch($stid)) {
        echo "Location id $locid is $city<br>\n";
}

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

aci_free_statement($stid);
aci_close($conn);

?>

示例 #2 aci_fetch() with aci_result()

<?php

$conn = aci_connect('sysdba', 'szoscar55', 'localhost:2003/OSRDB');
if (!$conn) {
        $e = aci_error();
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

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

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

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

aci_free_statement($stid);
aci_close($conn);

?>

注释

注意:
在5.0.0之前的PHP版本中,请改用acifetch()。

参见

aci_define_by_name()- 在 SELECT 中使用 PHP 变量作为定义的步骤

aci_fetch_all()-获取结果数据的所有行到一个数组

aci_fetch_array()- 以关联数组或数字数组形式返回查询的下一行

aci_fetch_assoc()-将查询的下一行作为关联数组返回

aci_fetch_object()-将查询的下一行作为对象返回

aci_fetch_row()-以数字数组形式返回查询的下一行

aci_fetch()-将下一行提取到结果缓冲区