<?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. 【定制Android系统】Android O 在ROM中添加自己的 so 库(1)——Android.mk 与 Android.bp 的区别【转】

    本文转载自: 版权声明:本文为博主原创文章,转载时请注明原作者及出处.    https://blog.csdn.net/u014248312/article/details/82020204需求:在 ...

  2. 比较好的MySQL索引原理

    MySQL索引原理及慢查询优化 - 美团技术团队 https://tech.meituan.com/2014/06/30/mysql-index.html

  3. 论文笔记:Learning how to Active Learn: A Deep Reinforcement Learning Approach

    Learning how to Active Learn: A Deep Reinforcement Learning Approach 2018-03-11 12:56:04 1. Introduc ...

  4. [JavaScript] - replaceAll,将字符串中的字母或数字等全部替换掉的方式

    原题 function DNAtoRNA(dna) { // create a function which returns an RNA sequence from the given DNA se ...

  5. 写前端页面步骤----vue+iview

    1:用iview构建基本HTML页面 2:在export default{ }中写一个data(){return:{变量:值}}全局对象,用于传递与绑定HTML参数. 3:在export defaul ...

  6. 关于jQ的Ajax操作

    jQ的Ajax操作 什么是AJAX AJAX = 异步的javascript和XML(Asynchronous Javascript and XML) 它不是一门编程语言,而是利用JavaScript ...

  7. React Native 异步存储

    异步存储 http://blog.csdn.net/yulianlin/article/details/52473456

  8. 再谈java编码

    一篇好文:从原理上搞懂编码——究竟什么是编码?什么是解码?什么是字节流? encode,即把字符按照指定的<编码gbk utf-8等>编码成该<编码>所表示的字节 decode ...

  9. win10上安装keras

    下载Anaconda https://www.anaconda.com/ 点击进入下载界面 选择Windows版本64位,python3.7 下载完成后 ,双击安装 等待安装完成! 安装MinGW包, ...

  10. CentOS7 下curl使用

    curl工具工具的主页:https://curl.haxx.se/NAMEcurl - transfer a URL SYNOPSIScurl [options] [URL...] DESCRIPTI ...