Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.