Re: PDO Prevent duplicate field names?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 3, 2012 at 12:38 AM, Scott Baker <bakers@xxxxxxxxxxxx> wrote:
> On 07/02/2012 03:34 PM, Matijn Woudt wrote:
>> Why the #### would you want to return 2 columns with the same name?
>> To be short, there's no such function, so you have to:
>> 1) Rename one of the columns
>> 2) or, use fetch_row with numerical indexes instead of fetch_assoc.
>
> My "real world" scenario was this
>
> SELECT a.CustID, b.*
> FROM Customer a
> LEFT JOIN Sales B USING (CustID)
> WHERE a.CustID = 1234;
>
> In that case, there was a record in Customer, but not in Sales. Sales
> returned CustID as NULL, which overwrote the one from Customer.
>
> 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.
>

Which makes me wonder, why are you returning a.CustID, if b includes
CustID too and a.CustID == b.CustID?

As to why there are no checks,.. I guess it's just that it's not a
common error. And after all, all it does is set a value in an array
twice, that doesn't result in warnings elsewhere (thank god ;))

- Matijn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux