Re: PDO include table name prefixes in FETCH_ASSOC

From: Date: Wed, 24 Mar 2010 16:18:15 +0000
Subject: Re: PDO include table name prefixes in FETCH_ASSOC
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-47005@lists.php.net to get a copy of this message
On 24 March 2010 16:05, Aaron Paetznick <aaronp@critd.com> wrote: > Many of my MySQL tables have columns with the same name.  I want to have PDO > include table names in named result sets.  For example: > >  $sth = $dbh->prepare("SELECT * FROM table0, table1"); >  $result = $sth->fetchAll(PDO::FETCH_ASSOC); > > > I want $result to be organized like: > >  echo $result["table0.column0"]; >  echo $result["table0.column1"]; >  echo $result["table1.column0"]; >  echo $result["table1.column1"]; > > > Or, alternatively: > >  echo $result["table0"]["column0"]; >  echo $result["table0"]["column1"]; >  echo $result["table1"]["column0"]; >  echo $result["table1"]["column1"]; > > > Any ideas?  Thanks! > > > --Aaron > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > The data coming from the server dictates the column names, not PDO. If you need to identify the names, then use aliases in the SQL. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.db (#47005) next »