note 50549 added to function.extract
| From: | MichaelNewton at osu1 dot php dot net | Date: | Thu, 03 Mar 2005 01:23:14 +0000 |
| Subject: | note 50549 added to function.extract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85839@lists.php.net to get a copy of this message | ||
They say "If the result is not a valid variable name, it is not imported into the symbol
table."
What they should say is that if _any_ of the results have invalid names, _none_ of the variables get
extracted.
Under 4.3.10 on Windows 2000, I was pulling some mySQL records, but needed to convert two fields
into IP addresses:
<?
extract(mysql_fetch_assoc(mysql_query('SELECT * FROM foo')));
extract(mysql_fetch_assoc(mysql_query('SELECT INET_NTOA(bar) AS bar, INET_NTOA(baz) FROM
foo')));
?>
I had forgotten the second AS modifier in the SQL query. Because it couldn't extract a
variable called INET_NTOA(baz) into the symbol table, it didn't do either of them.
(BTW I don't normally stack functions up like that! Just to make a short example!)
----
Manual Page -- http://www.php.net/manual/en/function.extract.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50549
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50549&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50549&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50549&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50549&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50549&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50549&report=yes
Search -- http://master.php.net/manage/user-notes.php