FYI: Select queries and "AS" SQL keyword

29 views
Skip to first unread message

J. Fink

unread,
Mar 8, 2011, 11:21:47 PM3/8/11
to PDO_4D
For those of us who are used to PHP and it's associative arrays, by
default 4D returns the column name in all caps, whereas if the SQL
keyword "AS" is used to assign an alias, the alias's capitalization
(or lack of) is maintained. This is important as PHP is case sensitive
("Status" is not the same as "status" or "STATUS"). Also, it is ok to
alias the field with the same name ("SELECT FirstName AS FirstName
FROM People").

Alexandre Morgaut

unread,
Mar 9, 2011, 10:59:01 AM3/9/11
to PDO_4D
The SQL language is case insensitive.

"SELECT Name ...", "SELECT name ...", and "SELECT NAME ..." will
return the value of the same column.

PDO allow to fix the case of the returned column name with the
setAttribute(int $attribute , mixed $value ) method (
http://www.php.net/manual/fr/pdo.setattribute.php )

so PDO_4D should preserve it if you call that:

$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);

If it doesn't, it is a bug I invite you to submit (
http://pecl.php.net/bugs/report.php?package=PDO_4D )


Alexandre.
Reply all
Reply to author
Forward
0 new messages