Re: [PHP] PDO Prevent duplicate field names?

2012-07-03 Thread tamouse mailing lists
On Mon, Jul 2, 2012 at 5:38 PM, Scott Baker bak...@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

[PHP] PDO Prevent duplicate field names?

2012-07-02 Thread Scott Baker
$sql = SELECT First, Last, Age, 'Foobar' AS Last;; This is a simplified example of a SQL query where we're returning two fields with the same name (Last). When I do a fetch_assoc with this query I only get three fields, as the second Last field over writes the first one. I was hoping there was

Re: [PHP] PDO Prevent duplicate field names?

2012-07-02 Thread Matijn Woudt
On Tue, Jul 3, 2012 at 12:25 AM, Scott Baker bak...@canbytel.com wrote: $sql = SELECT First, Last, Age, 'Foobar' AS Last;; This is a simplified example of a SQL query where we're returning two fields with the same name (Last). When I do a fetch_assoc with this query I only get three fields,

Re: [PHP] PDO Prevent duplicate field names?

2012-07-02 Thread Scott Baker
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

Re: [PHP] PDO Prevent duplicate field names?

2012-07-02 Thread Matijn Woudt
On Tue, Jul 3, 2012 at 12:38 AM, Scott Baker bak...@canbytel.com 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

Re: [PHP] PDO Prevent duplicate field names?

2012-07-02 Thread Jim Lucas
On 07/02/2012 03:38 PM, Scott Baker 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