trying to make exception work, please help
Posted: Thu Nov 09, 2006 11:10 pm
Hi,
I have not used eception that much
please tell me what i am doing wrong here, My function which gives error is
I am calling it like this
I still get
Fatal error: Uncaught exception 'NonExistantClassException' with message 'The class specified for RecordBase::find_all() does not exist.' in /home/irfan/projects/sitemanager2/lib/helpers/record_base.php:298 Stack trace: #0 /home/irfan/projects/sitemanager2/app/common/controllers/basic_site_controller.php(39): RecordBase::find_all('Site', 'url = 'extended...') #1 /home/irfan/projects/sitemanager2/public/index.php(107): BasicSiteController->__construct() #2 {main} thrown in /home/irfan/projects/sitemanager2/lib/helpers/record_base.php on line 298
--------------------------------------------------------------------------------
I have not used eception that much
please tell me what i am doing wrong here, My function which gives error is
Code: Select all
public static function find_all($class_name, $where="1", $args="")
{
// check to make sure that the class passed actually exists.
if (!class_exists($class_name))
throw new NonExistantClassException('The class specified for RecordBase::find_all() does not exist.');
// extract all of the classes variables to get its primary key.
extract(get_class_vars($class_name));
// build the sql statement used to get the desired rows.
$sql = "SELECT * FROM `{$table_name}` WHERE {$where} {$args['group_by']} {$args['order_by']} {$args['having']} {$args['limit']}";
// calls the method to get the records we are searching for.
return self::find_by_sql($class_name, $sql, $args);
}Code: Select all
try{
$this->sites = Buyer::find_all("Buyer");
}
catch (NonExistantClassException $e )
{
// mail("you@site.com", "Query Error", $e->message);
die ( "I'm afraid there was an error with the database server, please contact the help desk.");
}I still get
Fatal error: Uncaught exception 'NonExistantClassException' with message 'The class specified for RecordBase::find_all() does not exist.' in /home/irfan/projects/sitemanager2/lib/helpers/record_base.php:298 Stack trace: #0 /home/irfan/projects/sitemanager2/app/common/controllers/basic_site_controller.php(39): RecordBase::find_all('Site', 'url = 'extended...') #1 /home/irfan/projects/sitemanager2/public/index.php(107): BasicSiteController->__construct() #2 {main} thrown in /home/irfan/projects/sitemanager2/lib/helpers/record_base.php on line 298
--------------------------------------------------------------------------------