Dear list.

I've been googling all day long for a solution to my problem. I've
found alot of information but I still can't seem to find a solution.
I've got 2 tables, user and card_forward. In card_forward I've got 2
foreign keys to the user table. The foreign keys are user_id_from and
user_id_to (so normal Propel join using the Propel methods doesn't do
it).

Here is the yaml schema for the tables:
user:
   _attributes: { defaultIdMethod: native }
   id:
   user_group_id: { type: integer, foreignTable: user_group,
foreignReference: id, onDelete: cascade }
   user_id:
   country_id:
   username: varchar(256)
   password: varchar(32)
   firstname: varchar(256)
   lastname: varchar(256)
   email: varchar(256)
   phone: varchar(256)
   mobile: varchar(256)
   address: varchar(256)
   city: varchar(256)
   custom_name: varchar(256)
   comp_name: varchar(256)

card_forward:
   _attributes: { defaultIdMethod: native }
   id:
   user_id_from: { type: integer, foreignTable: user,
foreignReference: id, onDelete: cascade }
   user_id_to: { type: integer, foreignTable: user, foreignReference:
id, onDelete: cascade }
   created_at:

This is what I've tried:

$c = new Criteria();
$c->addAscendingOrderByColumn(CardForwardPeer::CREATED_AT);
UserPeer::addSelectColumns($c);
CardForwardPeer::addSelectColumns($c);
$c->addJoin(CardForwardPeer::USER_ID_TO, UserPeer::ID);
$forwardsToSql = BasePeer::doSelect($c);

while ($forwardsToSql->next()) {
    $omClass = UserPeer::getOMClass();
    $cls = Propel::import($omClass);
    $userObj = new $cls();
    $userObj->hydrate($forwardsToSql);

    $omClass = CardForwardPeer::getOMClass();
    $cls = Propel::import($omClass);
    $forwardObj = new $cls();
    $forwardObj->hydrate($forwardsToSql);
}

The $userObj is like I think it's supposed to be and I can echo for
instance $userObj->getId().
I get the following exception error while setting the $forwardObj:
Error populating CardForward object [wrapped: Unable to convert value
at column 4 to timestamp: 1]

It's like the index is corrupted or something so
CardForward::CREATED_AT isn't parsed right.

I have tried to use:
$c->addSelectColumn(UserPeer::FIRSTNAME);
$c->addSelectColumn(CardForwardPeer::CREATED_AT);
instead of:
UserPeer::addSelectColumns($c);
CardForwardPeer::addSelectColumns($c);

I've also tried simplier ways like I saw you guys doing here on the
list, like:
$c = new Criteria();
$c->addJoin(UserPeer::ID, CardForwardPeer::USER_ID_TO);
$fusers = UserPeer::doSelect($c);
Then I echo $fusers[0]->getId() and it works fine but when I want to
access the CardForward variables I don't know how to do that. Here are
some examples I've tried to use:
echo $fusers[0]->getCardForward()->getCreatedAt();
echo $fusers[0]->getCreatedAt();

All help would be great. I hope I'm sending this to the right
list. :-)

P.S. What does the $forwardsToSql->next() do? That is, I'm supposed to
use a while loop through it but then in the while loop itself I parse
$forwardsToSql as a whole to the $userObj->hydrate() method. Does it
just change some variables in $forwardsToSql for each use (for each
loop)? I've tested print_r on $forwardsToSql in the loop and it seems
like there's an index number that gets incremented and some fields
variables get changed (with the SQL variables->values). This is just
something I'm wondering, I much much more need help with the join
itself so please don't let this disturb you too much. :-)

Thanks all.

Regards,
Kristinn.


--~--~---------~--~----~------------~-------~--~----~
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