symfony get data from array

Posted by iggnition on Stack Overflow See other posts from Stack Overflow or by iggnition
Published on 2010-05-10T09:39:52Z Indexed on 2010/05/10 9:44 UTC
Read the original article Hit count: 412

Filed under:
|
|
|

Hi,

I'm trying to use an SQL query to get data from my database into the template of a symfony project.

my query:

SQL:
SELECT l.loc_id AS l__loc_id, l.naam AS l__naam, l.straat AS l__straat, 
l.huisnummer AS l__huisnummer, l.plaats AS l__plaats, l.postcode AS l__postcode,
l.telefoon AS l__telefoon, l.opmerking AS l__opmerking, o.org_id AS o__org_id, o.naam AS o__naam 
FROM locatie l 
LEFT JOIN organisatie o 
ON l.org_id = o.org_id

This is generated by this DQL:

DQL:
 $this->q = Doctrine_Query::create()
->select('l.naam, o.naam, l.straat, l.huisnummer, l.plaats, l.postcode, l.telefoon, l.opmerking')
->from('Locatie l')
->leftJoin('l.Organisatie o')
->execute();

But now when i try to acces this data in the template by either doing:

<?php foreach ($q as $locatie): ?>
<?php echo $locatie['o.naam'] ?>

or

<?php foreach ($q as $locatie): ?>
<?php echo $locatie['o__naam'] ?>

i get the error from symfony:

500 | Internal Server Error | Doctrine_Record_UnknownPropertyException
Unknown record property / related component "o__naam" on "Locatie"

Does anyone know what is going wrong here? i dont know how to call the value from the array if the names in both query's dont work.

© Stack Overflow or respective owner

Related posts about symfony

Related posts about doctrine