$r = mysqli_query($c, $s);
1,$s為insert, update, delete時(shí),$r為true或false;
2,$s為select時(shí),$r為resultSet或false;
1,$s為insert, update, delete時(shí),$r為true或false;
2,$s為select時(shí),$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); //索引數(shù)組 == mysqli_fetch_row($rs)
mysqli_fetch_array($rs, MYSQLI_ASSOC); //關(guān)聯(lián)數(shù)組 == mysqli_fetch_assoc($rs)
mysqli_fetch_array($rs, MYSQLI_BOTH); //混合數(shù)組 == mysqli_fetch_array($rs)
mysqli_fetch_array($rs, MYSQLI_ASSOC); //關(guān)聯(lián)數(shù)組 == mysqli_fetch_assoc($rs)
mysqli_fetch_array($rs, MYSQLI_BOTH); //混合數(shù)組 == mysqli_fetch_array($rs)
mysqli_query("set names utf8"); //設(shè)置插入和檢索數(shù)據(jù)庫(kù)的字符的格式為utf8
header("Content-Type:text/html;charset=utf8"); //用于設(shè)置頁(yè)面文檔的顯示格式
header("Content-Type:text/html;charset=utf8"); //用于設(shè)置頁(yè)面文檔的顯示格式
//get the result set
$rs = mysqli_query($conn, $s);
while($row = get_every_row($rs)){ //do sth with array $row }
1, mysqli_fetch_row(); 索引數(shù)組
2, mysqli_fetch_assoc(); 關(guān)聯(lián)數(shù)組
3, mysqli_fetch_array(); 不知啥數(shù)組
4, mysqli_fetch_object(); 對(duì)象
$rs = mysqli_query($conn, $s);
while($row = get_every_row($rs)){ //do sth with array $row }
1, mysqli_fetch_row(); 索引數(shù)組
2, mysqli_fetch_assoc(); 關(guān)聯(lián)數(shù)組
3, mysqli_fetch_array(); 不知啥數(shù)組
4, mysqli_fetch_object(); 對(duì)象
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
//query database
$rs = mysqli_query($conn, $queryString);
$rs = mysqli_query($conn, $queryString);
2018-04-21
//select database
mysqli_select_db($conn, 'test');
mysqli_select_db($conn, 'test');
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);
2018-04-21
//判斷是否支持某種數(shù)據(jù)庫(kù)
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