php oci fetch,oci_fetch_array - PHP 5 中文文档

(PHP 5)

oci_fetch_array–Returns the next row from the result data as an associative or

numeric array, or both

Description

array oci_fetch_array

( resource statement [, int mode] )

Returns an array, which corresponds to the next result row or FALSE

in

case of error or there is no more rows in the result.

oci_fetch_array()

returns an array with both

associative and numeric indices.

注:

本函数对

PHP NULL

值设定 NULL 字段。

Optional second parameter can be any combination of the following

constants:

OCI_BOTH

– return an array with both associative

and numeric indices (the same as OCI_ASSOC

+ OCI_NUM

). This is the default behavior.

OCI_ASSOC

– return an associative array

(as oci_fetch_assoc()

works).

OCI_NUM

– return a numeric array,

(as oci_fetch_row()

works).

OCI_RETURN_NULLS

– create empty elements

for the NULL

fields.

OCI_RETURN_LOBS

– return the value of a LOB

of the descriptor.

Default mode

is OCI_BOTH

.

It should be mentioned here, that oci_fetch_array()

is insignificantly

slower, than

oci_fetch_row()

, but much more handy.

注:

Don’t forget, that Oracle returns all field names in uppercase and

associative indices in the result array will be uppercased too.

例子 1. oci_fetch_array()

with OCI_BOTH

example

<?php $connection = oci_connect("apelsin", "kanistra");$query = "SELECT id, name FROM fruits";$statement = oci_parse ($connection, $query);oci_execute ($statement);while ($row = oci_fetch_array ($statement, OCI_BOTH)) {echo $row[0]." and ".$row['ID']." is the same
";echo $row[1]." and ".$row['NAME']." is the same
";}?>

例子 2. oci_fetch_array()

with

OCI_NUM

example

<?php $connection = oci_connect("user", "password");$query = "SELECT id, name, lob_field FROM fruits";$statement = oci_parse ($connection, $query);oci_execute ($statement);while ($row = oci_fetch_array ($statement, OCI_NUM)) {echo $row[0]."
";echo $row[1]."
";echo $row[2]->read(100)."
";//this will output first 100 bytes from LOB}?>

例子 3. oci_fetch_array()

with

OCI_ASSOC

example

<?php $connection = oci_connect("user", "password");$query = "SELECT id, name, lob_field FROM fruits";$statement = oci_parse ($connection, $query);oci_execute ($statement);while ($row = oci_fetch_array ($statement, OCI_NUM)) {echo $row['ID']."
";echo $row['NAME']."
";echo $row['LOB_FIELD']."
";//this will output "Object id #1"}?>

例子 4. oci_fetch_array()

with

OCI_RETURN_LOBS

example

<?php $connection = oci_connect("user", "password");$query = "SELECT id, name, lob_field FROM fruits";$statement = oci_parse ($connection, $query);oci_execute ($statement);while ($row = oci_fetch_array ($statement, OCI_NUM)) {echo $row[0]."
";echo $row[1]."
";echo $row['LOB_FIELD']."
";//this will output LOB's content}?>

See also oci_fetch_assoc()

,

oci_fetch_object()

,

oci_fetch_row()

and

oci_fetch_all()

.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值