位置: 编程技术 - 正文

PHP:oci_fetch_all()的用法_Oracle函数

编辑:rootadmin
oci_fetch_all

推荐整理分享PHP:oci_fetch_all()的用法_Oracle函数,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 5, PECL OCI8 >= 1.1.0)

oci_fetch_all — 获取结果数据的所有行到一个数组

说明 int oci_fetch_all ( resource $statement , array &$output [, int $skip [, int $maxrows [, int $flags ]]] )

oci_fetch_all() 从一个结果中获取所有的行到一个用户定义的数组。oci_fetch_all() 返回获取的行数,出错则返回 FALSE。skip 是从结果中获取数据时,最开始忽略的行数(默认值是 0,即从第一行开始)。maxrows 是要读取的行数,从第 skip 行开始(默认值是 -1,即所有行)。

flags 参数可以是下列值的任意组合: OCI_FETCHSTATEMENT_BY_ROW OCI_FETCHSTATEMENT_BY_COLUMN(默认值) OCI_NUM OCI_ASSOC

Example #1 oci_fetch_all() 例子

<?php/*oci_fetch_allexamplembrittonatverinetdotcom()*/$conn=oci_connect("scott","tiger");$stmt=oci_parse($conn,"select*fromemp");oci_execute($stmt);$nrows=oci_fetch_all($stmt,$results);if($nrows>0){echo"<tableborder="1">n";echo"<tr>n";foreach($resultsas$key=>$val){echo"<th>$key</th>n";}echo"</tr>n";for($i=0;$i<$nrows;$i++){echo"<tr>n";foreach($resultsas$data){echo"<td>$data[$i]</td>n";}echo"</tr>n";}echo"</table>n";}else{echo"Nodatafound<br/>n";}echo"$nrowsRecordsSelected<br/>n";oci_free_statement($stmt);oci_close($conn);?>

oci_fetch_all() 如果出错则返回 FALSE。

Note:

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

参数

statement

有效的 OCI8 报表标识符由 oci_parse() 创建,被 oci_execute()或 REF CURSOR statement 标识执行。

output

The variable to contain the returned rows.

LOB columns are returned as strings, where Oracle supports conversion.

See oci_fetch_array() for more information on how data and types are fetched.

skip

The number of initial rows to discard when fetching the result. The default value is 0, so the first row onwards is returned.

maxrows

The number of rows to return. The default is -1 meaning return all the rows from skip + 1 onwards.

flags

Parameter flags indicates the array structure and whether associative arrays should be used. oci_fetch_all() Array Structure Modes Constant Description OCI_FETCHSTATEMENT_BY_ROW The outer array will contain one sub-array per query row. OCI_FETCHSTATEMENT_BY_COLUMN The outer array will contain one sub-array per query column. This is the default.

Arrays can be indexed by column heading or numerically. oci_fetch_all() Array Index Modes Constant Description OCI_NUM Numeric indexes are used for each column&#;s array. OCI_ASSOC Associative indexes are used for each column&#;s array. This is the default.

PHP:oci_fetch_all()的用法_Oracle函数

Use the addition operator "+" to choose a combination of array structure and index modes.

Oracle&#;s default, non-case sensitive column names will have uppercase array keys. Case-sensitive column names will have array keys using the exact column case. Use var_dump() on output to verify the appropriate case to use for each query.

Queries that have more than one column with the same name should use column aliases. Otherwise only one of the columns will appear in an associative array.

返回值

Returns the number of rows in output, which may be 0 or more, 或者在失败时返回 FALSE.

范例

Example #2 oci_fetch_all() example

<?php$conn=oci_connect('hr','welcome','localhost/XE');if(!$conn){$e=oci_error();trigger_error(htmlentities($e['message'],ENT_QUOTES),E_USER_ERROR);}$stid=oci_parse($conn,'SELECTPOSTAL_CODE,CITYFROMlocationsWHEREROWNUM<3');oci_execute($stid);$nrows=oci_fetch_all($stid,$res);echo"$nrowsrowsfetched<br>n";var_dump($res);//

Example #3 oci_fetch_all() example with OCI_FETCHSTATEMENT_BY_ROW

<?php$conn=oci_connect('hr','welcome','localhost/XE');if(!$conn){$e=oci_error();trigger_error(htmlentities($e['message'],ENT_QUOTES),E_USER_ERROR);}$stid=oci_parse($conn,'SELECTPOSTAL_CODE,CITYFROMlocationsWHEREROWNUM<3');oci_execute($stid);$nrows=oci_fetch_all($stid,$res,null,null,OCI_FETCHSTATEMENT_BY_ROW);echo"$nrowsrowsfetched<br>n";var_dump($res);//

Example #4 oci_fetch_all() with OCI_NUM

<?php$conn=oci_connect('hr','welcome','localhost/XE');if(!$conn){$e=oci_error();trigger_error(htmlentities($e['message'],ENT_QUOTES),E_USER_ERROR);}$stid=oci_parse($conn,'SELECTPOSTAL_CODE,CITYFROMlocationsWHEREROWNUM<3');oci_execute($stid);$nrows=oci_fetch_all($stid,$res,null,null,OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM);echo"$nrowsrowsfetched<br>n";var_dump($res);//

注释

Note:

Using skip is very inefficient. All the rows to be skipped are included in the result set that is returned from the database to PHP. They are then discarded. It is more efficient to use SQL to restrict the offset and range of rows in the query. See oci_fetch_array() for an example.

Note:

Queries that return a large number of rows can be more memory efficient if a single-row fetching function like oci_fetch_array() is used.

Note:

查询返回巨大数量的数据行时,通过增大oci8.default_prefetch值或使用 oci_set_prefetch() 可显著提高性能。

Note:

In PHP versions before 5.0.0 you must use ocifetchstatement() instead. 在当前版本中,旧的函数名还可以被使用,但已经被废弃并不建议使用。

参见

oci_fetch() - Fetches the next row into result-buffer oci_fetch_array() - Returns the next row from a query as an associative or numeric array oci_fetch_assoc() - Returns the next row from a query as an associative array oci_fetch_object() - Returns the next row from a query as an object oci_fetch_row() - Returns the next row from a query as a numeric array oci_set_prefetch() - 设置预提取行数

PHP:oci_execute()的用法_Oracle函数 oci_execute(PHP5,PECLOCI8=1.1.0)oci_execute执行一条语句说明booloci_execute(resource$stmt[,int$mode])oci_execute()执行一条之前被解析过的语句(见oci_parse())。可选参数mode

PHP:oci_error()的用法_Oracle函数 oci_error(PHP5,PECLOCI8=1.1.0)oci_error返回上一个错误说明arrayoci_error([resource$source])对于大多数错误,参数是最适合的资源句柄。对于oci_connect(),oci_new_connect()

PHP:oci_bind_by_name()的用法_Oracle函数 oci_bind_by_name(PHP5,PECLOCI8=1.1.0)oci_bind_by_name绑定一个PHP变量到一个Oracle位置标志符说明booloci_bind_by_name(resource$stmt,string$ph_name,mixed&$variable[,int$maxlength[,int$type

标签: PHP:oci_fetch_all()的用法_Oracle函数

本文链接地址:https://www.jiuchutong.com/biancheng/281117.html 转载请保留说明!

上一篇:PHP:oci_connect()的用法_Oracle函数(php odbc)

下一篇:PHP:oci_execute()的用法_Oracle函数(php oci_connect)

  • 私立幼儿园需要纳税吗
  • 一般纳税人销售货物税率
  • 公司内部个人股份怎么算
  • 非正常损失的进项税额转出公式
  • 增值税发票遗失怎么操作
  • 社保基数申报怎么看是否成功
  • 专票多少钱
  • 车辆保险费发票的会计分录
  • 收到三代手续费返还
  • 销售方退款回来要怎么处理?
  • 竞价服务费放在哪个会计科目?
  • 企业生产成本核算的一般程序为
  • 出口货物免抵退税额城市维护建设税
  • 增值税进项发票网上勾选平台
  • 福利费税前扣除标准2023
  • 零余额账户期末怎么结转?
  • 暂估入库企业所得税税率
  • 帮别人公司过账100万,再转30回给他
  • windows11结束任务快捷键
  • 应收账款的账面余额公式
  • 电脑删文件需要授权
  • 广告公司员工
  • 一般纳税人增值税申报表怎么填写
  • 购物卡销售的重点工作是什么
  • 预交税款分录
  • 工程改造怎么做账
  • php技巧
  • 银行借款利息支出计入什么科目
  • 财务人员如何管控费用支出
  • 利润的构成要素包括
  • php扩展开发参考手册
  • 出口退税款计入营业外收入要交所得税吗
  • 使用服务器
  • 长期借款的主要成本包括
  • 没有校验码的发票可以报销吗
  • 新建利润表
  • 财政零余额账户存款
  • 锅炉维修项目
  • 代开增值税发票需要预交所得税吗
  • 长期股权投资损益调整
  • discuz怎么使用
  • 不单独计价的包装物是什么意思
  • 新手任务税控设备申请
  • 年度亏损计提所得税吗
  • 买赠业务税务处理
  • 上一年度主营业务成本多计提了
  • 收到上个月退税会计分录
  • 税控盘费用进什么科目
  • 外贸企业汇兑损益如何减少
  • 技术服务费怎么交税
  • 预算会计年末如何结账
  • 红字信息表开错了对方已开发票怎么处理
  • 吊装费是属于什么报销项目
  • 固定资产二级明细科目有哪些
  • 成本会计主要做什么工作
  • mysql -u -p -s
  • 用命令创建文件夹
  • win8.1安装秘钥
  • win10动态磁贴不更新
  • linux find . -name命令
  • 本地磁盘文件系统
  • linux的tar命令用法
  • 在linux 上使用QQ聊天程序
  • 高德地图自动跳出来
  • opengl光照设置
  • linux 常用命令大全及其详解
  • js查看浏览器信息
  • 梦见擦窗户框
  • Node.js中的全局变量有哪些
  • 批处理文件教程
  • jquery的认识和使用
  • 编写shell脚本,批量建立用户
  • Python中str is not callable问题详解及解决办法
  • js根据对象的key来获取对应值
  • node.js权威指南
  • js原型使用场景
  • 如何在js中实现输入
  • 潍坊市区面积多大
  • 请问在哪里可以培训护工
  • 税控卡丢失怎么办
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设