Saturday, February 20, 2010

Programmer - which method is more efficient: set a class property; or return the result?

Programmer Question

Please consider this example. (PHP)



class Database{  
private $result;
private $conn;

function query($sql){
$result = $this->conn->query($sql);
// Set the Database::$result ?? Or return the value and avoid setting property?
return $result;
// $this->result = $result;
}
}


what are the advantages of both these methods? Where are they applicable?

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails