Check all:
Fetch_all ()
Mysqli_num
Mysqli_assoc
Mysqli_both
Query one:
Fetch_row ()
FETCH_ASSOC ()
Fetch_object ()
Fetch_array ()
Mysqli_num
Mysqli_assoc
Mysqli_both
To speak in code:
<?PHPHeader(' Content-type:text/html;charset=utf-8 ');$mysqli=Newmysqli ();$mysqli= @Mysqli_connect(' localhost:3306 ', ' root ', ' root ', ' Zhy ');if($mysqli-errno) { die(' MYSQL CONNECT error--'.$mysqli->connect_errno. ': '.$mysqli-connect_error);}$mysqli->set_charset (' UTF8 ');$sql= ' SELECT * from user ';$mysqli _result=$mysqli->query ($sql);if($mysqli _result){ /******************************************************************** * Query all records * $rows = $mysqli _result->fetch_ All (Mysqli_num); Returns the indexed array by default * $rows = $mysqli _result->fetch_all (MYSQLI_ASSOC); Returns the associative array * $rows = $mysqli _result->fetch_all (mysqli_both); Returns an indexed array and an associative array ********************************************************************///$rows = $mysqli _result->fetch_all ();//Var_dump ($rows); /** * Query a return index array*/ $rows=$mysqli _result-Fetch_row (); Var_dump($rows); Echo' ; /** * Query a return associative array*/ $rows=$mysqli _result-Fetch_assoc (); Var_dump($rows); Echo' ; /** * Query a return object form*/ $rows=$mysqli _result-Fetch_object (); Var_dump($rows); Echo' ; /** * Query a return associative array method contains three properties * mysqli_num * MYSQLI_ASSOC * Mysqli_both*/ $rows=$mysqli _result-Fetch_array (MYSQLI_ASSOC); Var_dump($rows); Echo' ; /** * Move result set internal pointer*/ $mysqli _result->data_seek (0); while($rows=$mysqli _result-Fetch_assoc ()) { Var_dump($rows); Echo' <br/? '; } $mysqli _result-Free ();}Else{ die(' MYSQL QUERY error--'.$mysqli->errno. ': '.$mysqli-error);}$mysqli->close ();
PHP Mysqli Learning (iii) query operations