Jump to content

Help in Symfony Left Join show in view file


marknt

Recommended Posts

Hello guys, I'm using symfony framework. How can I access the 'table2.fieldname' in my indexSuccess.php? I can't figure out how to use the getSfGuardUser() function. Maybe there's a way to access the 'table2.fieldname'?

 

I have been searching the online doc but to no luck I couldn't find the solution I'm looking for.

 

SQL Query

SELECT gi.title, up.first_name, up.last_name, t.shirt_image
FROM game_image gi
LEFT JOIN user_profile up ON up.user_id = gi.user_id 
LEFT JOIN team t ON t.team_id = up.team_id 

 

action.class.php

<?php
$pager = new sfPropelPager('GameImage', ;
$c = new Criteria();
$c->addJoin(GameImagePeer::USER_ID, UserProfilePeer::USER_ID, Criteria::LEFT_JOIN);
$c->addJoin(UserProfilePeer::TEAM_ID, TeamPeer::TEAM_ID, Criteria::LEFT_JOIN);

$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter('page', 1));
$pager->setPeerMethod('doSelect');
$pager->init();
$this->pager = $pager;
?>

 

indexSuccess.php

<?php foreach($pager->getResults() as $thumb){ ?>
    <?php echo $thumb->getTitle(); // table1 fieldname ?>
    <?php echo $thumb->getSfGuardUser()->getUserProfile()->getFirstName(); // table2 fieldname ?>
<?php } ?>

 

It returns an error

Fatal error: Call to a member function getUserProfile() on a non-object in indexSuccess.php

 

How can I solve this problem?  :'(

 

Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.