Hi
I'm probably being incredibly stupid but nevermind.
I've got a simple database class using MDB2 which has the following function.
The connection part is fine however what I'm having a problem with is reading the [tt]$_results[/tt] in my PHP script.
For example I'm happy creating the class but if I do not how to parse the results in the script itself.
One more question, if there is an error it will return a boolean which means it has failed so would I do a [tt]gettype()[/tt] beforehand?
Cheers
Chris
I'm probably being incredibly stupid but nevermind.
I've got a simple database class using MDB2 which has the following function.
Code:
public function query($sql) {
$_result = null;
try {
$this->connect();
$_result =& $this->_connection->query($sql);
if (PEAR::isError($_result)) {
throw new Exception($_result->getMessage());
}
return $_result;
}
catch (Exception $error) {
print($error->getMessage());
return false;
}
$this->disconnect();
}
The connection part is fine however what I'm having a problem with is reading the [tt]$_results[/tt] in my PHP script.
For example I'm happy creating the class but if I do not how to parse the results in the script itself.
Code:
$db = new mySQL();
$result = $db->query("SELECT * FROM tblItems");
//What do I do with $result?
One more question, if there is an error it will return a boolean which means it has failed so would I do a [tt]gettype()[/tt] beforehand?
Cheers
Chris