Hi,

> I have an action class where i try to get the amount of left credits.
> so i'll try to make a function for that in the CreditsPeer.php file
> which is generated by propel. I call this function with this: "$this-
>
> >creditsLeft = CreditsPeer::getLeftCredits();"
>
> that function looks like this:
> public function getLeftCredits()
>         {
>                 $c = new Criteria();
>                 $c->addAlias('SUM('.self::AMOUNT.')', 'total');
>                 $c->add(self::USER_ID, $this->getUser()->getMemberId());
>                 $c->addGroupByColumn(CreditsPeer::USER_ID);
>                 $credits = self::doSelectOne($c);
>                 var_dump($credits);
>                 return $credits;
>         }

One problem I see going on here is that you are somehow misusing your
propel Peer classes. The functions in these classes are generally
meant to be static, so when you have `$this->getUser()->getMemberId()`
call in the peer, what "this" are you referring to?

You'd probably want to redefine that function to accept an instance of
your user class that it can work from, like:

public static function getLeftCredits($user) {
    ....
    $c->add(self::USER_ID, $user->getMemberId());
    ....
}

> And here is my problem, as you see I try to access the sfUser to call
> an own written function from the self written file myUser.class.php in
> the lib folder which looks like this:
> class myUser extends sfBasicSecurityUser
> {
>
>         public function getMemberId()
>         {
>                 return 1; # later will be a bit more of code..
>         }
>
> }

The lib/myUser class is not really tied to your user class that's most
likely defined in your database in any way. What I think you're meant
to do is to set your "user id" (say the primary key in the database)
into the user session upon a successful login in, then in your myUser
class, you can define something like a `getProfile()` method which
then retrieves the primary key from the session and does a db lookup/
retrieval to get your "real" user object, and then return that so you
can work on that -- that's how the sfGuardPlugin works anyhow ... so
if you're planning to switch over to that eventually, it wouldn't hurt
to set your stuff up now to work that way.

Hope that helps,
-steve


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to