I have PHP class that contain function for query data from database. The first one is
class x{
public $var1;
public $var2;
function __construct(){ }
function getX($primkey){
$sql = mysql_qyery("SELECT * FROM x_table WHERE primkey='$primkey'");
$row = mysq;_fetch_assoc($sql);
$this->var1 = $row['var1'];
$this->var2 = $row['var2'];
}
}
and another on is
class x{
public $var1;
public $var2;
function __construct(){ }
function getX($primkey){
$sql = mysql_qyery("SELECT * FROM x_table WHERE primkey='$primkey'");
$row = mysq;_fetch_assoc($sql);
return $row;
}
}
two class has some difference on function getX(). The first class put data from database to class variables but the second one return whole data from database via array.
I would like to know about performance of two class, which one is better. and which one is good for programming or any idea?
Regards.