One major question, one semi-related minor question:
I've got a class whose constructor takes some arguments and uses those to pull data from a database. However, it's entirely possible that the arguments won't find squat in the database. Can (and how can) I cause the constructor to just return FALSE rather than an object?
code summary of my rough guess
Sorta related question: I know the "foo() or die()" method of error handling, is there a way to do "foo() or return FALSE" ?
I've got a class whose constructor takes some arguments and uses those to pull data from a database. However, it's entirely possible that the arguments won't find squat in the database. Can (and how can) I cause the constructor to just return FALSE rather than an object?
code summary of my rough guess
Code:
class foo {
function foo ($arg)
{
$found = $this->populate($arg); // database lookup function, boolean return
if (!$found) return FALSE;
}
}
Sorta related question: I know the "foo() or die()" method of error handling, is there a way to do "foo() or return FALSE" ?