mysqli

Connection

$link = new mysqli('localhost', 'root', '', 'Store');
$link->close();

Query

$result = $link->query("SELECT * FROM Animal");
if($result){
	$result->free_result();
}

Fetch Assoc

if($result){
	$arr = [];
	while($row = $result->fetch_assoc()){
		$arr[] = $row;
	}
	$result->free_result();
}

Fetch Array

if($result){
	$arr = [];
	while($row = $result->fetch_array()){
		$arr[] = $row;
	}
	$result->free_result();
}

Fetch Object

if($result){
	$arr = [];
	while($row = $result->fetch_object()){
		$arr[] = $row;
	}
	$result->free_result();
}

Fetch Row

if($result){
	$arr = [];
	while($row = $result->fetch_row()){
		$arr[] = $row;
	}
	$result->free_result();
}

Prepare

$stmt = $link->prepare('INSERT INTO Animal(AnimalName) VALUES (?)');
if($stmt){
	$stmt->close();
}

Bind Param

if($stmt){
	$name = 'Dog';
	$stmt->bind_param('s', $name);
	$ret = $stmt->execute();
	if($ret){
		if($stmt->affected_rows > 0){
			echo $stmt->insert_id;
		}
	}
	$stmt->close();
}

Call Procedure

$stmt = $link->prepare('CALL AddMember(?)');
if($stmt){
	$name = 'Cat';
	$stmt->bind_param('s', $name);
	$stmt->close();
}

Get Result

$id = 1;
$stmt = $link->prepare('SELECT * FROM Animal WHERE AnimalId = ?');
if($stmt){
	$stmt->bind_param('i', $id);
	$ret = $stmt->execute();
	if($ret){
		$result = $stmt->get_result();
		if($result){
			if($result->num_rows > 0){
				$row = $result->fetch_assoc();
				var_dump($row);
			}
			$result->free_result();
		}
	}
	$stmt->close();
}