<?php
class Database
{
private $host = 'localhost';
private $db_user = 'root';
private $db_pass = '';
private $db_name = 'social';
function connect()
{
$connection = mysqli_connect($this->host, $this->db_user, $this->db_pass,$this->db_name);
return $connection;
}
function read($query)
{
$con = $this->connect();
$result = mysqli_query($con, $query);
if(!$result)
{
return false;
}
else
{
$data = [];
while ($row = mysqli_fetch_assoc($result))
{
$data[] = $row;
}
return $data;
}
}
}
$db= new Database();
$result2 = $db->read("SELECT * FROM users where id=11 ");
echo "<pre>";
print_r($result2);
echo "</pre>";
echo $result2['first_name'];