$r = mysqli_query($c, $s);
1,$s为insert, update, delete时,$r为true或false;
2,$s为select时,$r为resultSet或false;
1,$s为insert, update, delete时,$r为true或false;
2,$s为select时,$r为resultSet或false;
2018-04-22
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);
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);
2018-04-22
//fetch the num of rows of the result
$nums = mysqli_num_rows($rs);
if($rs && mysqli_num_rows($rs))
$nums = mysqli_num_rows($rs);
if($rs && mysqli_num_rows($rs))
2018-04-22
//query database as object
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_object($rs)){
echo $row->name$row->age->fuck you <br>;
}
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_object($rs)){
echo $row->name$row->age->fuck you <br>;
}
2018-04-21
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_fetch_array($rs, MYSQLI_ASSOC); //关联数组 == mysqli_fetch_assoc($rs)
mysqli_fetch_array($rs, MYSQLI_BOTH); //混合数组 == mysqli_fetch_array($rs)
2018-04-21
mysqli_query("set names utf8"); //设置插入和检索数据库的字符的格式为utf8
header("Content-Type:text/html;charset=utf8"); //用于设置页面文档的显示格式
header("Content-Type:text/html;charset=utf8"); //用于设置页面文档的显示格式
2018-04-21
//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(); 对象
$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(); 对象
2018-04-21
//query database
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_array($rs)){
//do sth by $row
}
$rs = mysqli_query($conn, $queryString);
while($row = mysqli_fetch_array($rs)){
//do sth by $row
}
2018-04-21
//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);
$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>';
}
if(function_exists('mysqli_connect')){
echo 'mysqli extension has been installed.<br>';
}
2018-04-21
//connect database
$conn = mysqli_connect('localhost', 'root', '');
if($conn){
echo 'connect success.<br>';
}else{
exit('connect failed');
}
$conn = mysqli_connect('localhost', 'root', '');
if($conn){
echo 'connect success.<br>';
}else{
exit('connect failed');
}
2018-04-21
$con=mysqli_connect('127.0.0.1','root','123456')
$con->query('insert into imo(names,pwd)VALUES ("345","qwe")');
$con->query('insert into imo(names,pwd)VALUES ("345","qwe")');
2018-04-18