I have the following code and it works fine. However since I have overlapping col names in my table, I want $row to include the tableName in the keys of the resulting assoc array. I don't want to explicitly list the cols of each table and I'd like to accomplish this in one query.:
<[PHP]>
$dbh = Database::getConnection($database, 'r');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT cars.* , garages.* , parkingSpots.*
FROM cars, garages, parkingSpots
WHERE cars.id=:id AND
cars.garage_id = garages.id AND
cars.parkingSpot_id = parkingSpots.id ";
$stmt = $dbh->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
# note the asso array keys include the table name
# after this , I want $rows to look like this
Array
(
[0] => Array
(
[cars.id] => 38011
[cars.guid] =>
[cars.postal_code] => 90404
[cars.url] => www.14below.com
[cars.phone] => 310.451.5040
[cars.state] => CA
[cars.country_code] => US
[cars.time_zone] => PST
[cars.time_zone_detailed] => America/Los_Angeles
[cars.offset] => -8
[cars.dst] => yes
[cars.latitude] => 34.028496
[cars.longitude] => -118.470151
[cars.ticketing] =>
[cars.station] =>
[cars.ivn] => no
[garages.venue_type] =>
[garages.liveVenue] => yes
[garages.vip_experience] => no
[garages.ln_owned] => NOT_LN
[garages.deleted] => no
[garages.updated_at] => 2007-04-01 17:48:58
[garages.lock_version] => 1
[garages.venue_id] => 11051
[garages.name] => 14 Below
[garages.city] => Santa Monica
[parkingSpots.state_code] => CA
[parkingSpots.address1] => Corner Of 14th Street and Santa Monica Boulevard
[parkingSpots.address2] =>
[parkingSpots.soundex] =>
[parkingSpots.soundexSql] =>
[parkingSpots.metaphone] =>
[parkingSpots.locale] => en-us
[parkingSpots.country] => us
[parkingSpots.area_code] => 310
[parkingSpots.county_fips] => 06037
[parkingSpots.county] => Los Angeles
[parkingSpots.time_zone_name] => Pacific
[parkingSpots.market_code] => 1
[parkingSpots.zip_type] => S
[parkingSpots.state_name] => California
[parkingSpots.state_fips] => 06
[parkingSpots.msa_code] => 4480
)
)
<[/PHP]>
THanks
mrfabulous