Re: PDO Prevent duplicate field names?
| From: | tamouse mailing lists | Date: | Tue, 03 Jul 2012 08:01:43 +0000 |
| Subject: | Re: PDO Prevent duplicate field names? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318384@lists.php.net to get a copy of this message | ||
On Mon, Jul 2, 2012 at 5:38 PM, Scott Baker <bakers@canbytel.com> wrote:
> It was my mistake, and the SQL was easily fixed. But it woulda been nice
> to have PHP realize there was a dupe when it was building that array to
> return to me.
This is just not a province of PHP. What sort of behaviour would one
expect PHP to do given this scenario? It is surely not an error in
every case; I can see some code relying on this exact behaviour.
Making it some sort of option in PHP increases the complexity a great
deal, not only in trying to determine how to design and then *change*
the API to accommodate it, but in figuring out what exactly one might
*do*. Since SQL is a completely separate language from PHP, it makes
much more sense to learn to deal with these thing separately, and
understand what your SQL is doing. Indeed, SQL will happily return
multiple columns with the same column name; you must be aware of this
when writing it.