function __construct($id = -1) { if (self::$conn == Null) { self::$conn = mysqli_connect('localhost', 'root', 'osama', 'store'); } if ($id != -1) { $query = "select * from categories where id={$id} limit 1"; $result = mysqli_query(self::$conn, $query); $category = mysqli_fetch_assoc($result); $this->id = $id; $this->name = $category['name']; $this->parent = $category['parent']; } }