Skip to content

Instantly share code, notes, and snippets.

@lsmith77
Created February 2, 2017 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsmith77/6f352592b0a460fb0886f4cec82d51de to your computer and use it in GitHub Desktop.
Save lsmith77/6f352592b0a460fb0886f4cec82d51de to your computer and use it in GitHub Desktop.
propel join with additional condition on a date
// also tried using addJoinObject + addJoinCondition but either way the condition just gets ignored
$results = $this->getFooQuery()
->addJoin(
FooTableMap::COL_ID,
BarTableMap::COL_ITEM_ID,
Criteria::LEFT_JOIN
)
->addCond(BarTableMap::COL_UPDATED_AT, $updatedAt->format('Y-m-d H:i:s'), Criteria::LESS_THAN)
->toString()
;
@caillioux
Copy link

Source: http://propelorm.org/blog/2010/02/16/propel-query-by-example.html

/*

  • Retrieving articles authored by someone
    */
    // Propel 1.4
    $c = new Criteria();
    $c->addJoin(ArticlePeer::AUTHOR_ID, AuthorPeer::ID);
    $c->add(AuthorPeer::NAME, 'John Doe');
    $articles = ArticlePeer::doSelect($c);
    // Propel 1.5
    $articles = ArticleQuery::create()
    ->useAuthorQuery()
    ->filterByName('John Doe')
    ->endUse()
    ->find()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment