Does PHP allow you to add methods to a class outside the class definition?
This seems not to be straightforward since class prototypes are not allowed.
For instance, what I'm trying to do is add a method to the DB class (in
PEAR) that will do a database query, test if the result is an error/warning,
trigger and error/warning, and (if possible) return the result.
Something like:
DB::ecQuery(&$db, $query) {
$result = $db->query($query);
if(DB::isError($result)) {
triggerError(DB::errorMessage($result), E_USER_ERROR);
}
else if(DB::isWarning($result)) {
triggerError(DB::errorMessage($result), E_USER_WARNING);
}
return $result;
}
I can't just add this to my own local copy of PEAR, because my app will be a
public use app, and I'd like my users to have the convenience of using their
preinstalled versions of PEAR (although I've thought of doing something like
BinaryCloud, which includes a distribution of metabase in its distribution).
Also, in case you're wondering, I'm triggering these errors b/c I know my
app will appropriately set PHP error_reporting to a user-defined value.
As it is, I have a "static" class called "Error" with a method called
"dbQuery" that I'm using, but a class called "Error" doesn't seem
appropriate -- "DB" does.
Anybody know if this is possible?
Thanks.
Dean.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]