php-mysql数据库操作(php操作指南)

$link = mysqli_connect(“localhost”, “root”, “password”);

连接数据库

mysqli_select_db($link, “php”);

选择数据库“php”;

$sql = "SELECT * FROM admin ";

执行sql的语句;

r e s u l t = m y s q l i q u e r y ( result = mysqli_query( result=mysqliquery(link, $sql);

执行sql语句,对于对于增删改返回的是Boolean类型,对于查返回的是一个mysql结果集对象;

mysqli_fetch_array( r e s u l t ) ; 等 价 于 result);等价于 result);result->fetch_array()

是一个迭代器,从结果集中选择第一行关联数组,也可以是索引数组, r o w , row, rowrow[“user”]/$row[index]取得每一列,然后指针调整到下一个位置,当没有下一行的时候返回空

等价于输出下同;

mysqli_fetch_row($result);

与mysqli_fetch_array( r e s u l t ) ; 类 似 , 不 同 的 是 这 个 返 回 结 果 是 选 择 第 一 行 的 索 引 数 组 result);类似,不同的是这个返回结果是选择第一行的索引数组 result);row,用$row[index]取得每一列

mysqli_fetch_assoc($result);

类似于 r e s u l t − > f e t c h a r r a y ( ) , m y s q l i f e t c h r o w ( result->fetch_array(),mysqli_fetch_row( result>fetcharray()mysqlifetchrow(result);得到的是关联数组 r o w , 用 / row,用/ row,/row[‘user’];得到

mysqli_fetch_object($result)

也是一个迭代器,与mysqli_fetch_array( r e s u l t ) ; 类 似 , 但 返 回 的 是 一 个 对 象 result);类似,但返回的是一个对象 result);obj,用 $row->user取得每一列

mysqli_free_result($result);

释放数据库查询结果

mysqli_close($link);

释放数据库连接

mysqli_num_rows($result);

返回查询结果集的行数

mysqli_num_fields($result);

返回查询结果集的列

mysqli_data_seek($result,n)

取得结果集中的第n+1行结果集,n+1不能超过结果行数,相当于取得二维数组结果集的第n个索引。

返回的也是一个结果集,通过 r o w = m y s q l i f e t c h a r r a y ( row=mysqli_fetch_array( row=mysqlifetcharray(result)才能得到结果

$link->error

得到数据库操作失败的信息;

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

松果Tech

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值