View Single Post
Old 01-19-2008, 11:47 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

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
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote