note 9324 added to odbc_result
| From: | dac at felspar dot com | Date: | Fri, 27 Oct 2000 23:43:45 +0000 |
| Subject: | note 9324 added to odbc_result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7080@lists.php.net to get a copy of this message | ||
FWIW, ADO and similar ODBC-using interfaces also cannot distinguish between A.id and B.id. The easy
solution is aliasing in SQL:
Consider a table "A" consisting only of the column "id". Next, consider the
following query:
SELECT * FROM A JOIN B ON A.id=B.id
With ODBC, you'd be forced to use the numerical index, rather than the name. However, you could
rewrite the query, too:
SELECT A.id AS A_id, B.id AS B_id FROM A JOIN B ON A.id=B.id
This can be better on three counts:
Firstly, unless you really want everything in the result set, it might be faster. SQL servers can be
faster with "*", but often the networking will benefit from less data (Or a smaller tuple
width, if you're into database jargon).
Secondly, since you're forced into thinking about what you want out of the query, you'll
probably write better SQL as a result.
Thirdly, if you change the query - or tables - slightly, you don't have to revisit all your
code to cope with the change.
Aplogies for stating the obvious, and having no imagination with my examples.
http://www.php.net/manual/function.odbc-result.php