Wednesday, April 6, 2011

Doctrine to Propel snippet

I am using the Propel ORM with SF (1.4). I am writing a class, and I need to rewrite a query Doctrine query into Propel:

  $q = Doctrine_Core::getTable('sfGuardRememberKey')->createQuery('r')
        ->innerJoin('r.sfGuardUser u')
        ->where('r.remember_key = ?', $cookie);

  if ($q->count()){ // Do Something }

can anyone help with the conversion?

From stackoverflow
  • Try it and fix column names:

    $c = new Criteria;
    $c->addJoin(sfGuardRememberKeyPeer::USER_ID, sfGuardUserPeer::ID, Criteria:INNER_JOIN);
    $c->add(sfGuardRememberKeyPeer::REMEMBER_KEY, $cookie);
    $result = sfGuardRememberKeyPeer::doSelect($c);
    if(count($result)) // do something
    
    Stick it to THE MAN : Fixed a simple, single typo - then it worked like a charm. tx!

0 comments:

Post a Comment