Esempio n. 1
0
 public function testAddExplicitConditionWithOperator()
 {
     $j = new Join();
     $j->addExplicitCondition('a', 'foo', null, 'b', 'bar', null, '>=');
     $this->assertEquals('>=', $j->getOperator());
     $this->assertEquals('a.foo', $j->getLeftColumn());
     $this->assertEquals('b.bar', $j->getRightColumn());
 }
Esempio n. 2
0
 /**
  * This is the way that you should add a join of two tables.
  * Example usage:
  * <code>
  * $c->addJoin(ProjectPeer::ID, FooPeer::PROJECT_ID, Criteria::LEFT_JOIN);
  * // LEFT JOIN FOO ON (PROJECT.ID = FOO.PROJECT_ID)
  * </code>
  *
  * @param      mixed $left  A String with the left side of the join.
  * @param      mixed $right A String with the right side of the join.
  * @param      mixed $joinType A String with the join operator
  *                             among Criteria::INNER_JOIN, Criteria::LEFT_JOIN,
  *                             and Criteria::RIGHT_JOIN
  *
  * @return     Criteria A modified Criteria object.
  */
 public function addJoin($left, $right, $joinType = null)
 {
     if (is_array($left)) {
         $conditions = array();
         foreach ($left as $key => $value) {
             $condition = array($value, $right[$key]);
             $conditions[] = $condition;
         }
         return $this->addMultipleJoin($conditions, $joinType);
     }
     $join = new Join();
     // is the left table an alias ?
     $dotpos = strrpos($left, '.');
     $leftTableAlias = substr($left, 0, $dotpos);
     $leftColumnName = substr($left, $dotpos + 1);
     list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias);
     // is the right table an alias ?
     $dotpos = strrpos($right, '.');
     $rightTableAlias = substr($right, 0, $dotpos);
     $rightColumnName = substr($right, $dotpos + 1);
     list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias);
     $join->addExplicitCondition($leftTableName, $leftColumnName, $leftTableAlias, $rightTableName, $rightColumnName, $rightTableAlias, Join::EQUAL);
     $join->setJoinType($joinType);
     return $this->addJoinObject($join);
 }