<?php
Object-oriented way to access the database
Created object $db = new mysqli ("localhost", "root", "123", "MyDB");
Determine if the connection is faulted/*if (Mysqli_connect_error ()) {echo ' Connection failed! "; Exit }*/
!mysqli_connect_error () or Die ("Connection failed! ");
Write SQL statement $sql = "INSERT into Info values (' p010 ', ' Zhang San ', true, ' n002 ', ' 1988-2-3 ')";
Executes the SQL statement, the query statement returns the result set object, the other statements return TRUE or false $result = $db->query ($sql);
Reads data from the result set object//$attr = $result->fetch_all (mysqli_both); Returns all data in the form of a two-dimensional array//$attr = $result->fetch_array (); Returns the data that the current pointer points to//$attr = $result->fetch_assoc (); Returns the data that the current pointer points to (associative array)//$attr = $result->fetch_object (); Return object//$attr = $result->fetch_row (); Returns an indexed array of//var_dump ($ATTR); /* while ($attr = $result->fetch_row ()) {var_dump ($attr);} */
Var_dump ($result);
?>
Facing the object database