Re: PDO question: any way to resolve duplicate column names with PDO_FETCH_ASSOC?

From: Date: Thu, 19 May 2005 16:17:31 +0000
Subject: Re: PDO question: any way to resolve duplicate column names with PDO_FETCH_ASSOC?
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2377@lists.php.net to get a copy of this message
Wez Furlong wrote:
I suspect that you're also looking for a workable alternative when the driver doesn't support it; one possible suggestion is have a fetch mode that allows multiple columns with the same name to come back; we could represent this in PHP script space something like this: $row = array('price' => 100, 'id' => array(1 /* from first table */, 2 /* from second */)); You're still faced with the problem of having to figure out which version of id belongs to which table, but now you'd have a way to determine when you need to start poking around the SQL (and which names to look for), so that you can avoid doing it on every query. How does that sound?
I havent played around with the getColumnMeta() method really, but it requires a call for every column and provides alot of information that would not be needed for this. maybe there should be a getColumnNames() method that just returns an array with all the column names that is ordered just like a numerically indexed set of row data? That would mean an additional method call, but I think it would even be more useful. regards, Lukas

« previous php.pecl.dev (#2377) next »