Is there any purpose to unset $data
? Should i unset it if it contains large data?
<?php
require 'db.php';
class Test{
public $id = 0;
public $name;
public function __construct()
{
$this->getUserInfo();
echo $this->name;
}
private function getUserInfo()
{
global $db;
$query = $db->prepare('SELECT id,name FROM users WHERE group = :g LIMIT 1');
if ($query->execute(array('g' => 'admin')))
{
$data = $query->fetch(); // <--
$this->id = $data[0];
$this->name = $data[1];
return true;
}
}
}
(new Test);
?>