mysql_fetch_row,mysql_fetch_array,mysql_fetch_object,mysql_fetch_assoc区别
1.mysql_fetch_row 只能以索引下标取值,从0开始。
2.mysql_fetch_array 能以索引下标取值,也可以用字段名称取值。
3.mysql_fetch_object 对象方式取值, ->
4.mysql_fetch_assoc 只能以字段名称取值。
补充一点:
mysql_fetch_array函数是这样定义的:array mysql_fetch_array ( resource result [,
int result_type]),返回根据从结果集取得的行生成的数组,如果没有更多行则返回 FALSE。
mysql_fetch_array()
中可选的第二个参数 result_type 是一个常量,可以接受以下值:MYSQL_ASSOC,MYSQL_NUM 和 MYSQL_BOTH。其中:
1、mysql_fetch_assoc($result)==mysql_fetch_array($result,MYSQL_ASSOC);
2、mysql_fetch_row($result)==mysql_fetch_array($result,MYSQL_NUM);
所以mysql_fetch_array()函数在某种程度上可以算是mysql_fetch_row()与
mysql_fetch_assoc()的集合。另外,mysql_fetch_array()另外还有MYSQL_BOTH参数,将得到一个同时包含关
联和数字索引的数组。
Link:http://www.jb51.net/article/17853.htm
mysql_fetch_row,mysql_fetch_array,mysql_fetch_object,mysql_fetch_assoc区别的更多相关文章
- 【转】mysql_fetch_row , mysql_fetch_array , mysql_fetch_assoc 的区别
<?php $link = mysql_connect('localhost', 'root', ”); mysql_select_db('abc', $link); $sql = “selec ...
- mysql_fetch_array,mysql_fetch_row,mysql_fetch_assoc区别
array mysql_fetch_array ( result [, int result_type] ) 返回:根据从结果集取得的行生成的数组,如果没有更多行则返回 FALSE. int ...
- mysql_fetch_row,mysql_fetch_array,mysql_fetch_assoc的区别
<?php $link=mysql_connect('localhost','root',”); mysql_select_db('abc',$link); $sql = “select * f ...
- 40)PHP,mysql_fetch_row和mysql_fetch_array和mysql_fetch_assoc的区别
分析: mysql_fetch_row,这个函数是从结果集中取一行作为枚举数据,从和指定的结果标识关联的结果集中取得一行数据并作为数组返回.每个结果的列储存在一个数组的单元中,偏移量从 开始. 注意, ...
- 40)PHP,mysql_fetch_row,mysql_fetch_array,mysql_fetch_assoc的区别
分析: mysql_fetch_row,这个函数是从结果集中取一行作为枚举数据,从和指定的结果标识关联的结果集中取得一行数据并作为数组返回.每个结果的列储存在一个数组的单元中,偏移量从 开始. 注意, ...
- mysql 纸 mysql_fetch_array OR mysql_fetch_assoc OR mysql_fetch_row
<?php $con = mysql_connect("localhost", "root", "123456");if (!$con ...
- 2019-07-24 PHP中mysql_fetch_assoc 和 mysql_fetch_array 有什么区别?
mysql_fetch_assoc() 函数从结果集中取得一行作为关联数组 来看下面的例子: 数据库中有上述几条数据,一般我们想取用就要按照如下代码: $con = mysql_connect('12 ...
- mysql_fetch_assoc 跟mysql_fetch_array 有什么区别?
mysql_fetch_assoc 得到的是关联数组. Array ( [0] => Array ( [title] => 特价9.9包邮 EFOLAR/依芙拉 BB粉润腮红粉 饼 蘑菇 ...
- PHP常用函数整理
推荐网址:http://php.net/manual/zh/http://www.w3cschool.cc/php/php-ref-array.html 错误报告: error_reporting(E ...
随机推荐
- codeblocks 配置交叉编译和调试环境
我要用codeblocks交叉编译和调试arm开发板上的程序,宿主机是ubuntu12.04.开发板是嵌入式linux操作系统. 1.配置交叉编译环境 由上到下,1处直接选择即可.2处是你交叉编译器安 ...
- mysql之触发器before和after的区别(2)
我们先做个测试: 接上篇日志建的商品表g和订单表o和触发器 假设:假设商品表有商品1,数量是10: 我们往订单表插入一条记录: insert into o(gid,much) values(1,20) ...
- javaScript 连续子数列最大和
<!DOCTYPE html> <html> <head> <title></title> <meta charset=utf-8&g ...
- mysql mmm高可用架构设计
项目概述:搭建主从,双主,安装Perl模块 安装配置mmm软件 测试 硬件环境:4台虚拟PC 软件环境:rehl6.5 MySQL-5.6.26 percona-xtrabackup-2.3.4 ...
- hibernate 知识梳理
一.hibernate背景介绍: 作者: Gavin King 分hibernate ORM(for relation db),OGM(for nosql db),hearch,validator,t ...
- Delphi XE5教程8:使用Delphi命名空间
// Project file declarations... //项目文件声明… program MyCompany.ProjectX.ProgramY; // Unit source file d ...
- haproxy 常用acl规则与会话保持
一.常用的acl规则 haproxy的ACL用于实现基于请求报文的首部.响应报文的内容或其它的环境状态信息来做出转发决策,这大大增强了其配置弹性.其配置法则通常分为两 步,首先去定义ACL,即定义一个 ...
- 将Unity3D游戏移植到Android平台上
将Unity3D游戏移植到Android平台是一件很容易的事情,只需要在File->Build Settings中选择Android平台,然后点击Switch Platform并Build出ap ...
- Oracle 10g下载链接
用迅雷下载: http://download.oracle.com/otn/linux/oracle10g/10201/10201_database_linux_x86_64.cpio.gz http ...
- XCODE快捷键和功能汇总篇(不断更新)
快捷键 command+b(build) 编译 command+r(run) 运行编译后程序鼠标放在代码元素上,按command然后单击,可以看到元素的属性