01-19-2008, 11:47 PM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 482
Thanks: 51
|
Hi Sam,
Looking good so far
A couple of suggestions though, since you're using public/private keywords for the functions it wouldn't hurt to use them for the variables as well.
PHP Code:
protected $connection = NULL;
protected $query = NULL;
Also, might be worth putting some error checking in there. Since you're doing it in PHP5, might as well use exceptions for it:
PHP Code:
public function DBQuery($sql)
{
if (!$this->query = mysql_query($sql))
{
throw new Exception('Query error: ' . mysql_error());
}
return $this->query;
}
Then in your PHP you could use something like this to check for the error:
PHP Code:
try
{
$db->query("SELECT something FROM somewhere");
}
catch (Exception $e)
{
echo 'Oops, an error occured! - Error returned was: ' . $e->getMessage();
}
Just makes for neater errors than plain old mysql_errors(), particularly when you are outputting the error to the visitor.
Other than that, looks good
Alan
|
|
|