<?php
/**
数据库连接 **/
$conn=mysqli_connect('localhost:3306','root','root');
if(!$conn){
die("could not connect:".mysqli_error($conn));
}
mysqli_query($conn , "set names utf8");
$sec=mysqli_select_db($conn,'wc');
if(!$sec){
die("error".mysqli_error($conn));
}
$sql="select * from ss";
$retval=mysqli_query($conn,$sql);
if(!$retval){
die("无法读取数据:".mysqli_error($conn));
}
print_r($retval);
while($row=mysqli_fetch_array($retval,MYSQLI_ASSOC)){
echo '<br/>';
print_r($row);
$arr[]=$row;
}
var_dump($arr);
mysqli_free_result($retval);
mysqli_close($conn);
/*3中解析方法
mysqli_fetch_array($retval)查询结果
Array ( [0] => 1 [id] => 1 [1] => 12 [a] => 12 [2] => 34 [b] => 34 [3] => 11 [c] => 11 )
Array ( [0] => 2 [id] => 2 [1] => 65 [a] => 65 [2] => 42 [b] => 42 [3] => 16 [c] => 16 )
Array ( [0] => 3 [id] => 3 [1] => 91 [a] => 91 [2] => 95 [b] => 95 [3] => 93 [c] => 93 )
mysqli_fetch_array($retval,MYSQLI_ASSOC)
Array ( [id] => 1 [a] => 12 [b] => 34 [c] => 11 )
Array ( [id] => 2 [a] => 65 [b] => 42 [c] => 16 )
Array ( [id] => 3 [a] => 91 [b] => 95 [c] => 93 ) mysqli_fetch_assoc($retval)查询结果
Array ( [id] => 1 [a] => 12 [b] => 34 [c] => 11 )
Array ( [id] => 2 [a] => 65 [b] => 42 [c] => 16 )
Array ( [id] => 3 [a] => 91 [b] => 95 [c] => 93 )
//mysqli_fetch_row($retval)
Array ( [0] => 1 [1] => 12 [2] => 34 [3] => 11 )
Array ( [0] => 2 [1] => 65 [2] => 42 [3] => 16 )
Array ( [0] => 3 [1] => 91 [2] => 95 [3] => 93 )
//mysqli_fetch_field($retval)
stdClass Object ( [name] => id [orgname] => id [table] => ss [orgtable] => ss [def] => [db] => wc [catalog] => def [max_length] => 1 [length] => 11 [charsetnr] => 63 [flags] => 49667 [type] => 3 [decimals] => 0 )
stdClass Object ( [name] => a [orgname] => a [table] => ss [orgtable] => ss [def] => [db] => wc [catalog] => def [max_length] => 2 [length] => 11 [charsetnr] => 63 [flags] => 32768 [type] => 3 [decimals] => 0 )
stdClass Object ( [name] => b [orgname] => b [table] => ss [orgtable] => ss [def] => [db] => wc [catalog] => def [max_length] => 2 [length] => 11 [charsetnr] => 63 [flags] => 32768 [type] => 3 [decimals] => 0 )
stdClass Object ( [name] => c [orgname] => c [table] => ss [orgtable] => ss [def] => [db] => wc [catalog] => def [max_length] => 2 [length] => 11 [charsetnr] => 63 [flags] => 32768 [type] => 3 [decimals] => 0 )
*/

mysqli的使用的更多相关文章

  1. 比Mysqli操作数据库更简便的方式 。PDO

    下面来说一下PDO 先画一张图来了解一下 mysqli是针对mysql这个数据库扩展的一个类 PDO是为了能访问更多数据库 如果出现程序需要访问其他数据库的话就可以用PDO来做 PDO数据访问抽象层1 ...

  2. PHP 数据库连接工具类(MySQLI函数包装)

    ====================mysql===================== <?php class mysql { private $mysqli; private $resu ...

  3. php mysqli mysqli_query() mysqli_real_query()

    2016年11月26日 15:22:27 星期六 场景: PHP从mysql中读取数据 1. 一次性读取所有数据返给PHP 2. 每次循环只读取一掉记录 数据量小的时候可以使用第一种方法, 数据量很大 ...

  4. mysqli操作数据库

    1 连接数据库:可以使用对象或函数来连接(我们这里主要用mysqli对象,附带着函数连接) //创建mysqli对象(也可以叫做资源句柄) $_mysqli = new mysqli(); //连接数 ...

  5. php的mysql\mysqli\PDO(二)mysqli

    原文链接:http://www.orlion.ga/1147/ mysqli有面向对象风格和面向过程风格,个人感觉还是用面向对象风格比较好(毕竟是面向对象) 1.mysqli::_construct( ...

  6. PHP使用mysqli扩展库实现增删改查(面向对象版)

    mysqli扩展库是mysql扩展库的改进版本,在mysql扩展库的基础上提高了稳定性和效率,mysqli扩展库有两套东西,一套就是面向过程的mysqli另一套是面向对象的mysqli.操作方式大体和 ...

  7. 解决 Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in

    转载 php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql ext ...

  8. PHP mysql与mysqli事务详解

    官方对PHP连接到MySQL数据库服务器的三种主要的API简介如下: http://php.net/manual/zh/mysqli.overview.php PHP mysql与mysqli事务详解 ...

  9. mysql、mysqli、PDO一句话概括比较

    mysql.mysqli.PDO一句话概括比较 1 mysql扩展 (注:原始的,较差) 2 mysqli扩展(面向过程式) (注:比上面多了更多功能) 3 mysqli扩展(面向对象式) (注:比上 ...

  10. mysqli链接数据库:面向对象

    $mysqli = new mysqli('localhost','root','123','test');//检查连接是否成功if (mysqli_connect_error()){ //注意mys ...

随机推荐

  1. 237. 程序自动分析 【map+并查集】

    程序自动分析 描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3,…x1,x2,x3,…代表程序中出现的变量,给定n个形 ...

  2. 彻底了解 suid, sgid ,sticky权限

    sticky: 粘性的, 如 : sticky tape: 粘胶带 /tmp, /var/tmp: 位 sticky: 表示: 第一, 任何用户都可以在该目录下创建文件(编辑自己的文件),第二, 但是 ...

  3. gimp的使用笔记

    gimp是德国的开源软件! 跟其他软件一样, 包括file, edit, view, 还有select, color , filter, 和 window. 窗口window就包括所有的dockabl ...

  4. P3128 [USACO15DEC]最大流Max Flow

    思路 这个题哪里有那么费脑筋 我们可以树链剖分嘛LCT昨天学的时候睡着了,不是太会 两遍dfs+一个5行的BIT 其实树链剖分学好了对倍增和LCT理解上都有好处 一条路径上的修改 由于一条剖出来的链是 ...

  5. HIHOcoder 1457 后缀自动机四·重复旋律7

    思路 后缀自动机题目,题目本质上是要求求出所有不同的子串的和,SAM每个节点中存放的子串互不相同,所以对于每个节点的sum,可以发现是可以递推的,每个点对子节点贡献是sum[x]*10+c*sz[x] ...

  6. 比原链设计思考: 扩展性UTXO模型

    用户模型是比原链在最初就需要确定的重要数据结构, 团队的选择还是聚焦在两种典型的模型系统中,Account模型和UTXO模型,和其他大多数区块链设计一样, 选择了模型就决定了协议层的重要实现,两种模型 ...

  7. SQL语句执行的顺序机制

    From Where Group by Having Select 表达式 Distinct ORDER BY TOP/OFFSET-FETCH

  8. 【译】第40节---EF6-命令监听

    原文:http://www.entityframeworktutorial.net/entityframework6/database-command-interception.aspx 本节,将学习 ...

  9. 【Python】【Web开发】

    # [[Web开发]] ''' 最早的软件都是运行在大型机上的,软件使用者通过“哑终端”登陆到大型机上去运行软件.后来随着PC机的兴起,软件开始主要运行在桌面上,而数据库这样的软件运行在服务器端,这种 ...

  10. Jenkins--Credentials添加证书从git上拉代码

    直接上图: