为了账号安全,请及时绑定邮箱和手机立即绑定

PHP与MySQL关系大揭秘

难度初级
时长 2小时58分
学习人数
综合评分9.80
299人评价 查看评价
9.9 内容实用
9.8 简洁易懂
9.7 逻辑清晰
$r = mysqli_query($c, $s);
1,$s为insert, update, delete时,$r为true或false;
2,$s为select时,$r为resultSet或false;
1,$c = mysqli_connect($h, $u, $p);
2,mysqli_select_db($db);
3,$r = mysqli_query($c, $s);
4,$num = mysqli_num_rows($r);
5,$row = mysqli_fetch_row($r);
6,$row = mysqli_fetch_assoc($r);
7,$row = mysqli_fetch_array($r);
8,$n = mysqli_affected_rows($c);
9,mysqli_close($n);
//fetch the num of rows of the result
$nums = mysqli_num_rows($rs);
if($rs && mysqli_num_rows($rs))
//query database as object
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_object($rs)){
echo $row->name$row->age->fuck you <br>;
}
mysqli_fetch_array($rs, MYSQLI_NUM); //索引数组 == mysqli_fetch_row($rs)
mysqli_fetch_array($rs, MYSQLI_ASSOC); //关联数组 == mysqli_fetch_assoc($rs)
mysqli_fetch_array($rs, MYSQLI_BOTH); //混合数组 == mysqli_fetch_array($rs)
mysqli_query("set names utf8"); //设置插入和检索数据库的字符的格式为utf8
header("Content-Type:text/html;charset=utf8"); //用于设置页面文档的显示格式
//get the result set
$rs = mysqli_query($conn, $s);
while($row = get_every_row($rs)){ //do sth with array $row }
1, mysqli_fetch_row(); 索引数组
2, mysqli_fetch_assoc(); 关联数组
3, mysqli_fetch_array(); 不知啥数组
4, mysqli_fetch_object(); 对象
//query database
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_array($rs)){
//do sth by $row
}
//query database
$rs = mysqli_query($conn, $queryString);
//select database
mysqli_select_db($conn, 'test');
//close the database
mysqli_close($conn);
不会做就选最长的,靠谱儿。
//mysqli
$conn = mysqli_connect($hostname, $username, $password) or die('fuck you');
mysqli_select_db($dbname);
mysqli_query('set names "utf8"');
//PDO--php data object
$conn = new PDO("mysql:dbname=$dbname;host=$hostname", $username, $password);
//判断是否支持某种数据库
if(function_exists('mysqli_connect')){
echo 'mysqli extension has been installed.<br>';
}
//connect database
$conn = mysqli_connect('localhost', 'root', '');
if($conn){
echo 'connect success.<br>';
}else{
exit('connect failed');
}
$con=mysqli_connect('127.0.0.1','root','123456')
$con->query('insert into imo(names,pwd)VALUES ("345","qwe")');
课程须知
本课程是PHP中级课程 1、掌握PHP开发语言的基础语法知识 2、掌握MYSQL数据库中基础的增删改查语句
老师告诉你能学到什么?
1、精通最基本的PHP内置mysql函数 2、掌握对数据库增删改查的步骤 3、熟悉简单文章发布系统的开发流程 4、学会分析相似系统,实现举一反三

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消