note 70613 added to function.mysql-fetch-object
| From: | syntax at osu1 dot php dot net | Date: | Sun, 22 Oct 2006 01:00:57 +0000 |
| Subject: | note 70613 added to function.mysql-fetch-object | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118925@lists.php.net to get a copy of this message | ||
@Simon Paridon and others concerning SQL to php getting results via mysql_fetch_object:
Every query that would fail in a database frontend, such as MySQLs "Query Browser" and
only will work by using the `-marks will probably give results hardly accessible in PHP especially
if you have column names with "-" or " " in it.
Using the example of Simon Paridon: it is not possible to execute a query like:
SELECT id, user-id FROM unlucky_naming
only
SELECT id,
user-id FROM unlucky_naming
will work...
so either be a bit wiser when naming the colums (e.g. user_id)
or try it with
SELECT id, user-id AS user_id FROM unlucky_naming
(i have not tested it in PHP yet, but i guess this will fail as well, if you have a query like
"SELECT foo name FROM unlucky naming 2")
Somewhat down "amackenz at cs dot uml dot edu" mentioned to name sum, count etc. this may
be a good hint for newbies: increase the speed of your php applications by using (my)sql native
functions and save data transfer as well as processing time
----
Server IP: 217.13.201.10
Probable Submitter: 84.154.164.56
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-object.php
Edit -- https://master.php.net/note/edit/70613
Del: integrated -- https://master.php.net/note/delete/70613/integrated
Del: useless -- https://master.php.net/note/delete/70613/useless
Del: bad code -- https://master.php.net/note/delete/70613/bad+code
Del: spam -- https://master.php.net/note/delete/70613/spam
Del: non-english -- https://master.php.net/note/delete/70613/non-english
Del: in docs -- https://master.php.net/note/delete/70613/in+docs
Del: other reasons-- https://master.php.net/note/delete/70613
Reject -- https://master.php.net/note/reject/70613
Search -- https://master.php.net/manage/user-notes.php