Example #1
0
 /**
  * @link       http://propel.phpdb.org/trac/ticket/634
  */
 public function testHasSelectClause()
 {
     $c = new Criteria();
     $c->addSelectColumn("foo");
     $this->assertTrue($c->hasSelectClause());
     $c = new Criteria();
     $c->addAsColumn("foo", "bar");
     $this->assertTrue($c->hasSelectClause());
 }
Example #2
0
 /**
  * Adds a Criteria as subQuery in the From Clause.
  *
  * @see Criteria::addSelectQuery()
  *
  * @param     Criteria $subQueryCriteria Criteria to build the subquery from
  * @param     string   $alias            alias for the subQuery
  * @param     boolean  $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns
  *
  * @return ModelCriteria The current object, for fluid interface
  */
 public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAliasAndSelectColumns = true)
 {
     if (!$subQueryCriteria->hasSelectClause()) {
         $subQueryCriteria->addSelfSelectColumns();
     }
     parent::addSelectQuery($subQueryCriteria, $alias);
     if ($addAliasAndSelectColumns) {
         // give this query-model same alias as subquery
         if (null === $alias) {
             end($this->selectQueries);
             $alias = key($this->selectQueries);
         }
         $this->setModelAlias($alias, true);
         // so we can add selfSelectColumns
         $this->addSelfSelectColumns();
     }
     return $this;
 }