Object-oriented way to access the database
1. Building Objects
$db =new mysqli("localhost", "root", "123", "HR");
2. Determine if the connection is wrong
!mysqli_connect_erroR () or Die ("Connection failed! ");
3. Write SQL statements
$sql = "Inselt into info values (' p005 ', ' Summer ', ' 1 ', ' n003 ', ' 1997-5-10 ')"; Adding data into the database
4. Execute SQL statement, query statement returns result set object, other statements return TRUE or False
$result = $db->query($sql);
5. Reading data from the result set object
$attr = $result->fetch_all(Mysqli_both); Returns all data in a two-dimensional array
$attr = $result->fetch_array(); Returns the data that the current pointer points to
$attr = $result->fetch_assoc(); Returns the data (associative array) to which the current pointer is pointing
$attr = $result->fetch_object(); Return object
$attr = $result->fetch_row(); Returns an indexed array
Var_dump ($ATTR);
while ($attr = $result->fetch_row ())//while loop
{
Var_dump ($ATTR);
}
Database access (active basic format)