if a service is supposed to return a specific type of object if it finds its matching record on a table, what should it return if doesn't find a matching row?
null? false? empty object?
(maybe this should be on the theory forum)
return object from a service
Moderator: General Moderators
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
Code: Select all
return 0;i prefer to return false... because the operation failed.
but then again, i would use a reference as parameter in which the object has to be returned
this way you can check if the operation succeeded... and then acces the found object, because $thingie will be a reference to it...
but then again, i would use a reference as parameter in which the object has to be returned
Code: Select all
function lookup(&$thingie)
{
// lookup object
$thingie =& something;
// object was found, thus return true
return true;
}