Re: what happened to that new isset() like language

From: Date: Thu, 08 Jul 2004 16:40:37 +0000
Subject: Re: what happened to that new isset() like language
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-10986@lists.php.net to get a copy of this message
Christian Schneider <cschneid@cschneid.com> writes: > Before it gets forgotten: I still think that > $x = ifsetor(mixed var, mixed var [, ...]); > with expressions in all parts is the way to go. > > Example usage: > $a = ifsetor($_REQUEST['x'], $db->get('x'), 'default_x'); > > And I also think that the name ifsetor has to be reevaluated :-) This is the exact usage and meaning of the SQL function coalesce(). That may be an appropriate name. From the sqlite documentation: coalesce(X,Y,...) Return a copy of the first non-NULL argument. If all arguments are NULL then NULL is returned. There must be at least 2 arguments. And from the postgres documentation: COALESCE(value [, ...]) The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. This is often useful to substitute a default value for null values when data is retrieved for display, for example: SELECT COALESCE(description, short_description, '(none)') ... Like a CASE expression, COALESCE will not evaluate arguments that are not needed to determine the result; that is, arguments to the right of the first non-null argument are not evaluated. The coalesce() function is from the ANSI/ISO SQL:1999 standard, so its use has been around for a while. Derrell

« previous php.internals (#10986) next »