note 28419 added to function.extract
| From: | jasonmercer at yahoo dot com | Date: | Sun, 12 Jan 2003 21:22:34 +0000 |
| Subject: | note 28419 added to function.extract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42026@lists.php.net to get a copy of this message | ||
One quick amendment to the IFNULL suggestion for MySQL:
use of aliases is highly recommended, because most flavors of MySQL will not return the base field
name in the associative array but rather the entire function name itself.
Therefore, the better MySQL query should read:
$SQL = "SELECT IFNULL(field1,'n.a.') as field1 FROM table"
which will create an associate array with key 'field1' and value 'n.a.' (if
field1 is NULL) or 'foo' (if field1 is set to string "foo"). Without the alias
structure (i.e. "as field1"), mileage varies considerably on the name of the array key.
/jm
--
http://www.php.net/manual/en/function.extract.php
http://master.php.net/manage/user-notes.php?action=edit+28419
http://master.php.net/manage/user-notes.php?action=delete+28419
http://master.php.net/manage/user-notes.php?action=reject+28419