Propel 2 API
Class

Propel\Runtime\ActiveQuery\ModelCriteria

class ModelCriteria extends BaseModelCriteria

This class extends the Criteria by adding runtime introspection abilities in order to ease the building of queries.

A ModelCriteria requires additional information to be initialized.
Using a model name and tablemaps, a ModelCriteria can do more powerful things than a simple Criteria

magic methods:

Constants

EQUAL

Comparison type.

NOT_EQUAL

Comparison type.

ALT_NOT_EQUAL

Comparison type.

GREATER_THAN

Comparison type.

LESS_THAN

Comparison type.

GREATER_EQUAL

Comparison type.

LESS_EQUAL

Comparison type.

LIKE

Comparison type.

NOT_LIKE

Comparison type.

CONTAINS_ALL

Comparison for array column types

CONTAINS_SOME

Comparison for array column types

CONTAINS_NONE

Comparison for array column types

ILIKE

PostgreSQL comparison type

NOT_ILIKE

PostgreSQL comparison type

CUSTOM

Comparison type.

RAW

Comparison type

CUSTOM_EQUAL

Comparison type for update

DISTINCT

Comparison type.

IN

Comparison type.

NOT_IN

Comparison type.

ALL

Comparison type.

JOIN

Comparison type.

BINARY_AND

Binary math operator: AND

BINARY_OR

Binary math operator: OR

ASC

'Order by' qualifier - ascending

DESC

'Order by' qualifier - descending

ISNULL

'IS NULL' null comparison

ISNOTNULL

'IS NOT NULL' null comparison

CURRENT_DATE

'CURRENT_DATE' ANSI SQL function

CURRENT_TIME

'CURRENT_TIME' ANSI SQL function

CURRENT_TIMESTAMP

'CURRENT_TIMESTAMP' ANSI SQL function

LEFT_JOIN

'LEFT JOIN' SQL statement

RIGHT_JOIN

'RIGHT JOIN' SQL statement

INNER_JOIN

'INNER JOIN' SQL statement

LOGICAL_OR

logical OR operator

LOGICAL_AND

logical AND operator

FORMAT_STATEMENT

FORMAT_ARRAY

FORMAT_OBJECT

FORMAT_ON_DEMAND

Methods

__construct(string $dbName = null, string $modelName = null, string $modelAlias = null)

Creates a new instance with the default capacity which corresponds to the specified database.

from BaseModelCriteria
array getWith()

Gets the array of ModelWith specifying which objects must be hydrated together with the main object.

from BaseModelCriteria
ModelCriteria setWith(array $with)

Sets the array of ModelWith specifying which objects must be hydrated together with the main object.

from BaseModelCriteria
ModelCriteria setFormatter(string|AbstractFormatter $formatter)

Sets the formatter to use for the find() output Formatters must extend AbstractFormatter Use the ModelCriteria constants for class names: <code> $c->setFormatter(ModelCriteria::FORMAT_ARRAY); </code>

from BaseModelCriteria
AbstractFormatter getFormatter()

Gets the formatter to use for the find() output Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e.

from BaseModelCriteria
string getModelName()

Returns the name of the class for this model criteria

from BaseModelCriteria
ModelCriteria setModelName(string $modelName)

Sets the model name.

from BaseModelCriteria
getFullyQualifiedModelName()

from BaseModelCriteria
ModelCriteria setModelAlias(string $modelAlias, boolean $useAliasInSQL = false)

Sets the alias for the model in this query

from BaseModelCriteria
string getModelAlias()

Returns the alias of the main class for this model criteria

from BaseModelCriteria
string getModelAliasOrName()

Return the string to use in a clause as a model prefix for the main model

from BaseModelCriteria
string getModelShortName()

Return The short model name (the short ClassName for class with namespace)

from BaseModelCriteria
TableMap getTableMap()

Returns the TableMap object for this Criteria

from BaseModelCriteria
Traversable getIterator()

Execute the query with a find(), and return a Traversable object.

from BaseModelCriteria
ModelCriteria condition(string $conditionName, string $clause, mixed $value = null, mixed $bindingType = null)

Adds a condition on a column based on a pseudo SQL clause but keeps it for later use with combine() Until combine() is called, the condition is not added to the query Uses introspection to translate the column phpName into a fully qualified name <code> $c->condition('cond1', 'b.Title = ?', 'foo'); </code>

ModelCriteria filterBy(string $column, mixed $value, string $comparison = Criteria::EQUAL)

Adds a condition on a column based on a column phpName and a value Uses introspection to translate the column phpName into a fully qualified name Warning: recognizes only the phpNames of the main Model (not joined tables) <code> $c->filterBy('Title', 'foo'); </code>

ModelCriteria filterByArray(mixed $conditions)

Adds a list of conditions on the columns of the current model Uses introspection to translate the column phpName into a fully qualified name Warning: recognizes only the phpNames of the main Model (not joined tables) <code> $c->filterByArray(array( 'Title' => 'War And Peace', 'Publisher' => $publisher )); </code>

ModelCriteria where($clause, $value = null, $bindingType = null)

Adds a condition on a column based on a pseudo SQL clause Uses introspection to translate the column phpName into a fully qualified name <code> // simple clause $c->where('b.Title = ?', 'foo'); // named conditions $c->condition('cond1', 'b.Title = ?', 'foo'); $c->condition('cond2', 'b.ISBN = ?', 12345); $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); </code>

ModelCriteria having($clause, $value = null, $bindingType = null)

Adds a having condition on a column based on a pseudo SQL clause Uses introspection to translate the column phpName into a fully qualified name <code> // simple clause $c->having('b.Title = ?', 'foo'); // named conditions $c->condition('cond1', 'b.Title = ?', 'foo'); $c->condition('cond2', 'b.ISBN = ?', 12345); $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); </code>

ModelCriteria orderBy(string $columnName, string $order = Criteria::ASC)

Adds an ORDER BY clause to the query Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() Infers $column and $order from $columnName and some optional arguments Examples: $c->orderBy('Book.CreatedAt') => $c->addAscendingOrderByColumn(BookTableMap::CREATED_AT) $c->orderBy('Book.CategoryId', 'desc') => $c->addDescendingOrderByColumn(BookTableMap::CATEGORY_ID)

ModelCriteria groupBy(string $columnName)

Adds a GROUP BY clause to the query Usability layer on top of Criteria::addGroupByColumn() Infers $column $columnName Examples: $c->groupBy('Book.AuthorId') => $c->addGroupByColumn(BookTableMap::AUTHOR_ID)

ModelCriteria groupByClass(string $class)

Adds a GROUP BY clause for all columns of a model to the query Examples: $c->groupBy('Book'); => $c->addGroupByColumn(BookTableMap::ID); => $c->addGroupByColumn(BookTableMap::TITLE); => $c->addGroupByColumn(BookTableMap::AUTHOR_ID); => $c->addGroupByColumn(BookTableMap::PUBLISHER_ID);

ModelCriteria distinct()

Adds a DISTINCT clause to the query Alias for Criteria::setDistinct()

ModelCriteria limit(int $limit)

Adds a LIMIT clause (or its subselect equivalent) to the query Alias for Criteria:::setLimit()

ModelCriteria offset(int $offset)

Adds an OFFSET clause (or its subselect equivalent) to the query Alias for of Criteria::setOffset()

ModelCriteria select(mixed $columnArray)

Makes the ModelCriteria return a string, array, or ArrayCollection Examples: ArticleQuery::create()->select('Name')->find(); => ArrayCollection Object ('Foo', 'Bar')

array|string getSelect()

Retrieves the columns defined by a previous call to select().

Join getPreviousJoin()

This method returns the previousJoin for this ModelCriteria, by default this is null, but after useQuery this is set the to the join of that use

setPreviousJoin(Join $previousJoin)

This method sets the previousJoin for this ModelCriteria, by default this is null, but after useQuery this is set the to the join of that use

Join getJoin(string $name)

This method returns an already defined join clause from the query

ModelCriteria join(string $relation, string $joinType = Criteria::INNER_JOIN)

Adds a JOIN clause to the query Infers the ON clause from a relation name Uses the Propel table maps, based on the schema, to guess the related columns Beware that the default JOIN operator is INNER JOIN, while Criteria defaults to WHERE Examples: <code> $c->join('Book.Author'); => $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::INNER_JOIN); $c->join('Book.Author', Criteria::RIGHT_JOIN); => $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::RIGHT_JOIN); $c->join('Book.Author a', Criteria::RIGHT_JOIN); => $c->addAlias('a', AuthorTableMap::TABLE_NAME); => $c->addJoin(BookTableMap::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN); </code>

ModelCriteria addJoinCondition($name, $clause, $value = null, $operator = null, $bindingType = null)

Add another condition to an already added join

ModelCriteria setJoinCondition(string $name, mixed $condition)

Replace the condition of an already added join

ModelCriteria addJoinObject(Join $join, $name = null)

Add a join object to the Criteria

ModelCriteria joinWith(string $relation, string $joinType = Criteria::INNER_JOIN)

Adds a JOIN clause to the query and hydrates the related objects Shortcut for $c->join()->with() <code> $c->joinWith('Book.Author'); => $c->join('Book.Author'); => $c->with('Author'); $c->joinWith('Book.Author a', Criteria::RIGHT_JOIN); => $c->join('Book.Author a', Criteria::RIGHT_JOIN); => $c->with('a'); </code>

ModelCriteria with(string $relation)

Adds a relation to hydrate together with the main object The relation must be initialized via a join() prior to calling with() Examples: <code> $c->join('Book.Author'); $c->with('Author');

isWithOneToMany()

ModelCriteria withColumn(string $clause, string $name = null)

Adds a supplementary column to the select clause These columns can later be retrieved from the hydrated objects using getVirtualColumn()

ModelCriteria useQuery($relationName, $secondaryCriteriaClass = null)

Initializes a secondary ModelCriteria object, to be later merged with the current object

ModelCriteria endUse()

Finalizes a secondary criteria and merges it with its primary Criteria

ModelCriteria mergeWith(Criteria $criteria, string $operator = null)

Add the content of a Criteria to the current Criteria In case of conflict, the current Criteria keeps its properties

ModelCriteria clear()

Clear the conditions to allow the reuse of the query object.

setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin)

Sets the primary Criteria for this secondary Criteria

ModelCriteria getPrimaryCriteria()

Gets the primary criteria for this secondary Criteria

ModelCriteria addSelectQuery(Criteria $subQueryCriteria, string $alias = null, boolean $addAliasAndSelectColumns = true)

Adds a Criteria as subQuery in the From Clause.

ModelCriteria addSelfSelectColumns()

Adds the select columns for a the current table

ModelCriteria addRelationSelectColumns(string $relation)

Adds the select columns for a relation

static array getClassAndAlias(string $class)

Returns the class and alias of a string representing a model or a relation e.g.

static string getRelationName(string $relation)

Returns the name of a relation from a string.

ModelCriteria keepQuery(boolean $isKeepQuery = true)

Triggers the automated cloning on termination.

boolean isKeepQuery()

Checks whether the automated cloning on termination is enabled.

ObjectCollection|array|mixed find(ConnectionInterface $con = null)

Issue a SELECT query based on the current ModelCriteria and format the list of results with the current formatter By default, returns an array of model objects

mixed findOne(ConnectionInterface $con = null)

Issue a SELECT ...

mixed findOneOrCreate(ConnectionInterface $con = null)

Issue a SELECT ...

mixed findPk(mixed $key, ConnectionInterface $con = null)

Find object by primary key Behaves differently if the model has simple or composite primary key <code> // simple primary key $book = $c->findPk(12, $con); // composite primary key $bookOpinion = $c->findPk(array(34, 634), $con); </code>

mixed findPks(array $keys, ConnectionInterface $con = null)

Find objects by primary key Behaves differently if the model has simple or composite primary key <code> // simple primary key $books = $c->findPks(array(12, 56, 832), $con); // composite primary key $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); </code>

mixed findBy(string $column, mixed $value, ConnectionInterface $con = null)

Apply a condition on a column and issues the SELECT query

mixed findByArray(mixed $conditions, ConnectionInterface $con = null)

Apply a list of conditions on columns and issues the SELECT query <code> $c->findByArray(array( 'Title' => 'War And Peace', 'Publisher' => $publisher ), $con); </code>

mixed findOneBy(mixed $column, mixed $value, ConnectionInterface $con = null)

Apply a condition on a column and issues the SELECT ...

mixed findOneByArray(mixed $conditions, ConnectionInterface $con = null)

Apply a list of conditions on columns and issues the SELECT ...

integer count(ConnectionInterface $con = null)

Issue a SELECT COUNT(*) query based on the current ModelCriteria

doCount($con = null)

PropelModelPager paginate(int $page = 1, int $maxPerPage = 10, ConnectionInterface $con = null)

Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit.

integer delete(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria An optional hook on basePreDelete() can prevent the actual deletion

integer deleteAll(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria deleting all rows in the table An optional hook on basePreDelete() can prevent the actual deletion

integer doDeleteAll(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria deleting all rows in the table This method is called by ModelCriteria::deleteAll() inside a transaction

integer update(mixed $values, ConnectionInterface $con = null, boolean $forceIndividualSaves = false)

Issue an UPDATE query based the current ModelCriteria and a list of changes.

integer doUpdate(array $values, ConnectionInterface $con, boolean $forceIndividualSaves = false)

Issue an UPDATE query based the current ModelCriteria and a list of changes.

DataFetcherInterface doSelect($con $con = null)

Builds, binds and executes a SELECT query based on the current object.

configureSelectColumns()

string getAliasedColName(string $colName)

Changes the table part of a a fully qualified column name if a true model alias exists e.g.

static string getShortName(string $fullyQualifiedClassName)

Return the short ClassName for class with namespace

ModelCriteria addUsingAlias($p1, $value = null, $operator = null)

Overrides Criteria::add() to force the use of a true table alias if it exists

array getParams()

Get all the parameters to bind to this criteria Does part of the job of createSelectSql() for the cache

__call($name, $arguments)

Handle the magic Supports findByXXX(), findOneByXXX(), filterByXXX(), orderByXXX(), and groupByXXX() methods, where XXX is a column phpName.

__clone()

Ensures deep cloning of attached objects

ModelCriteria leftJoin($relation)

Adds a LEFT JOIN clause to the query

ModelCriteria rightJoin($relation)

Adds a RIGHT JOIN clause to the query

ModelCriteria innerJoin($relation)

Adds a INNER JOIN clause to the query

Details

in BaseModelCriteria at line 36
public __construct(string $dbName = null, string $modelName = null, string $modelAlias = null)

Creates a new instance with the default capacity which corresponds to the specified database.

Parameters

string $dbName The dabase name
string $modelName The phpName of a model, e.g. 'Book'
string $modelAlias The alias for the model in this query, e.g. 'b'

in BaseModelCriteria at line 51
public array getWith()

Gets the array of ModelWith specifying which objects must be hydrated together with the main object.

Return Value

array

See also

with()

in BaseModelCriteria at line 64
public ModelCriteria setWith(array $with)

Sets the array of ModelWith specifying which objects must be hydrated together with the main object.

Parameters

array $with

Return Value

ModelCriteria The current object, for fluid interface

in BaseModelCriteria at line 84
public ModelCriteria setFormatter(string|AbstractFormatter $formatter)

Sets the formatter to use for the find() output Formatters must extend AbstractFormatter Use the ModelCriteria constants for class names: <code> $c->setFormatter(ModelCriteria::FORMAT_ARRAY); </code>

Parameters

string|AbstractFormatter $formatter a formatter class name, or a formatter instance

Return Value

ModelCriteria The current object, for fluid interface

Exceptions

InvalidArgumentException

in BaseModelCriteria at line 105
public AbstractFormatter getFormatter()

Gets the formatter to use for the find() output Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e.

PropelObjectsFormatter

Return Value

AbstractFormatter

in BaseModelCriteria at line 120
public string getModelName()

Returns the name of the class for this model criteria

Return Value

string

in BaseModelCriteria at line 133
public ModelCriteria setModelName(string $modelName)

Sets the model name.

This also sets `this->modelTableMapName` and `this->tableMap`.

Parameters

string $modelName

Return Value

ModelCriteria The current object, for fluid interface

in BaseModelCriteria at line 150
public getFullyQualifiedModelName()

in BaseModelCriteria at line 163
public ModelCriteria setModelAlias(string $modelAlias, boolean $useAliasInSQL = false)

Sets the alias for the model in this query

Parameters

string $modelAlias The model alias
boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default)

Return Value

ModelCriteria The current object, for fluid interface

in BaseModelCriteria at line 180
public string getModelAlias()

Returns the alias of the main class for this model criteria

Return Value

string The model alias

in BaseModelCriteria at line 190
public string getModelAliasOrName()

Return the string to use in a clause as a model prefix for the main model

Return Value

string The model alias if it exists, the model name if not

in BaseModelCriteria at line 200
public string getModelShortName()

Return The short model name (the short ClassName for class with namespace)

Return Value

string The short model name

in BaseModelCriteria at line 210
public TableMap getTableMap()

Returns the TableMap object for this Criteria

Return Value

TableMap

in BaseModelCriteria at line 226
public Traversable getIterator()

Execute the query with a find(), and return a Traversable object.

The return value depends on the query formatter. By default, this returns an ArrayIterator
constructed on a Propel\Runtime\Collection\PropelCollection.
Compulsory for implementation of \IteratorAggregate.

Return Value

Traversable

Exceptions

LogicException

at line 96
public ModelCriteria condition(string $conditionName, string $clause, mixed $value = null, mixed $bindingType = null)

Adds a condition on a column based on a pseudo SQL clause but keeps it for later use with combine() Until combine() is called, the condition is not added to the query Uses introspection to translate the column phpName into a fully qualified name <code> $c->condition('cond1', 'b.Title = ?', 'foo'); </code>

Parameters

string $conditionName A name to store the condition for a later combination with combine()
string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
mixed $value A value for the condition
mixed $bindingType A value for the condition

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::add()

at line 119
public ModelCriteria filterBy(string $column, mixed $value, string $comparison = Criteria::EQUAL)

Adds a condition on a column based on a column phpName and a value Uses introspection to translate the column phpName into a fully qualified name Warning: recognizes only the phpNames of the main Model (not joined tables) <code> $c->filterBy('Title', 'foo'); </code>

Parameters

string $column A string representing thecolumn phpName, e.g. 'AuthorId'
mixed $value A value for the condition
string $comparison What to use for the column comparison, defaults to Criteria::EQUAL

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::add()

at line 141
public ModelCriteria filterByArray(mixed $conditions)

Adds a list of conditions on the columns of the current model Uses introspection to translate the column phpName into a fully qualified name Warning: recognizes only the phpNames of the main Model (not joined tables) <code> $c->filterByArray(array( 'Title' => 'War And Peace', 'Publisher' => $publisher )); </code>

Parameters

mixed $conditions An array of conditions, using column phpNames as key

Return Value

ModelCriteria The current object, for fluid interface

See also

filterBy()

at line 170
public ModelCriteria where($clause, $value = null, $bindingType = null)

Adds a condition on a column based on a pseudo SQL clause Uses introspection to translate the column phpName into a fully qualified name <code> // simple clause $c->where('b.Title = ?', 'foo'); // named conditions $c->condition('cond1', 'b.Title = ?', 'foo'); $c->condition('cond2', 'b.ISBN = ?', 12345); $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); </code>

Parameters

$clause
$value
$bindingType

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::add()

at line 205
public ModelCriteria having($clause, $value = null, $bindingType = null)

Adds a having condition on a column based on a pseudo SQL clause Uses introspection to translate the column phpName into a fully qualified name <code> // simple clause $c->having('b.Title = ?', 'foo'); // named conditions $c->condition('cond1', 'b.Title = ?', 'foo'); $c->condition('cond2', 'b.ISBN = ?', 12345); $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); </code>

Parameters

$clause
$value
$bindingType

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::addHaving()

at line 235
public ModelCriteria orderBy(string $columnName, string $order = Criteria::ASC)

Adds an ORDER BY clause to the query Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() Infers $column and $order from $columnName and some optional arguments Examples: $c->orderBy('Book.CreatedAt') => $c->addAscendingOrderByColumn(BookTableMap::CREATED_AT) $c->orderBy('Book.CategoryId', 'desc') => $c->addDescendingOrderByColumn(BookTableMap::CATEGORY_ID)

Parameters

string $columnName The column to order by
string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC

Return Value

ModelCriteria The current object, for fluid interface

at line 265
public ModelCriteria groupBy(string $columnName)

Adds a GROUP BY clause to the query Usability layer on top of Criteria::addGroupByColumn() Infers $column $columnName Examples: $c->groupBy('Book.AuthorId') => $c->addGroupByColumn(BookTableMap::AUTHOR_ID)

Parameters

string $columnName The column to group by

Return Value

ModelCriteria The current object, for fluid interface

at line 286
public ModelCriteria groupByClass(string $class)

Adds a GROUP BY clause for all columns of a model to the query Examples: $c->groupBy('Book'); => $c->addGroupByColumn(BookTableMap::ID); => $c->addGroupByColumn(BookTableMap::TITLE); => $c->addGroupByColumn(BookTableMap::AUTHOR_ID); => $c->addGroupByColumn(BookTableMap::PUBLISHER_ID);

Parameters

string $class The class name or alias

Return Value

ModelCriteria The current object, for fluid interface

at line 315
public ModelCriteria distinct()

Adds a DISTINCT clause to the query Alias for Criteria::setDistinct()

Return Value

ModelCriteria The current object, for fluid interface

at line 330
public ModelCriteria limit(int $limit)

Adds a LIMIT clause (or its subselect equivalent) to the query Alias for Criteria:::setLimit()

Parameters

int $limit Maximum number of results to return by the query

Return Value

ModelCriteria The current object, for fluid interface

at line 345
public ModelCriteria offset(int $offset)

Adds an OFFSET clause (or its subselect equivalent) to the query Alias for of Criteria::setOffset()

Parameters

int $offset Offset of the first result to return

Return Value

ModelCriteria The current object, for fluid interface

at line 374
public ModelCriteria select(mixed $columnArray)

Makes the ModelCriteria return a string, array, or ArrayCollection Examples: ArticleQuery::create()->select('Name')->find(); => ArrayCollection Object ('Foo', 'Bar')

ArticleQuery::create()->select('Name')->findOne();
=> string 'Foo'

ArticleQuery::create()->select(array('Id', 'Name'))->find();
=> ArrayCollection Object (
array('Id' => 1, 'Name' => 'Foo'),
array('Id' => 2, 'Name' => 'Bar')
)

ArticleQuery::create()->select(array('Id', 'Name'))->findOne();
=> array('Id' => 1, 'Name' => 'Foo')

Parameters

mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name')

Return Value

ModelCriteria The current object, for fluid interface

at line 398
public array|string getSelect()

Retrieves the columns defined by a previous call to select().

Return Value

array|string A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name')

See also

select()

at line 409
public Join getPreviousJoin()

This method returns the previousJoin for this ModelCriteria, by default this is null, but after useQuery this is set the to the join of that use

Return Value

Join the previousJoin for this ModelCriteria

at line 420
public setPreviousJoin(Join $previousJoin)

This method sets the previousJoin for this ModelCriteria, by default this is null, but after useQuery this is set the to the join of that use

Parameters

Join $previousJoin The previousJoin for this ModelCriteria

at line 432
public Join getJoin(string $name)

This method returns an already defined join clause from the query

Parameters

string $name The name of the join clause

Return Value

Join A join object

at line 458
public ModelCriteria join(string $relation, string $joinType = Criteria::INNER_JOIN)

Adds a JOIN clause to the query Infers the ON clause from a relation name Uses the Propel table maps, based on the schema, to guess the related columns Beware that the default JOIN operator is INNER JOIN, while Criteria defaults to WHERE Examples: <code> $c->join('Book.Author'); => $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::INNER_JOIN); $c->join('Book.Author', Criteria::RIGHT_JOIN); => $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::RIGHT_JOIN); $c->join('Book.Author a', Criteria::RIGHT_JOIN); => $c->addAlias('a', AuthorTableMap::TABLE_NAME); => $c->addJoin(BookTableMap::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN); </code>

Parameters

string $relation Relation to use for the join
string $joinType Accepted values are null, 'left join', 'right join', 'inner join'

Return Value

ModelCriteria The current object, for fluid interface

at line 527
public ModelCriteria addJoinCondition($name, $clause, $value = null, $operator = null, $bindingType = null)

Add another condition to an already added join

Parameters

$name
$clause
$value
$operator
$bindingType

Return Value

ModelCriteria The current object, for fluid interface

at line 559
public ModelCriteria setJoinCondition(string $name, mixed $condition)

Replace the condition of an already added join

Parameters

string $name The relation name or alias on which the join was created
mixed $condition A Criterion object, or a condition name

Return Value

ModelCriteria The current object, for fluid interface

at line 583
public ModelCriteria addJoinObject(Join $join, $name = null)

Add a join object to the Criteria

Parameters

Join $join
$name

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::addJoinObject()

at line 613
public ModelCriteria joinWith(string $relation, string $joinType = Criteria::INNER_JOIN)

Adds a JOIN clause to the query and hydrates the related objects Shortcut for $c->join()->with() <code> $c->joinWith('Book.Author'); => $c->join('Book.Author'); => $c->with('Author'); $c->joinWith('Book.Author a', Criteria::RIGHT_JOIN); => $c->join('Book.Author a', Criteria::RIGHT_JOIN); => $c->with('a'); </code>

Parameters

string $relation Relation to use for the join
string $joinType Accepted values are null, 'left join', 'right join', 'inner join'

Return Value

ModelCriteria The current object, for fluid interface

at line 639
public ModelCriteria with(string $relation)

Adds a relation to hydrate together with the main object The relation must be initialized via a join() prior to calling with() Examples: <code> $c->join('Book.Author'); $c->with('Author');

$c->join('Book.Author a', Criteria::RIGHT_JOIN);
$c->with('a');
</code>
WARNING: on a one-to-many relationship, the use of with() combined with limit()
will return a wrong number of results for the related objects

Parameters

string $relation Relation to use for the join

Return Value

ModelCriteria The current object, for fluid interface

at line 666
public isWithOneToMany()

at line 683
public ModelCriteria withColumn(string $clause, string $name = null)

Adds a supplementary column to the select clause These columns can later be retrieved from the hydrated objects using getVirtualColumn()

Parameters

string $clause The SQL clause with object model column names e.g. 'UPPER(Author.FirstName)'
string $name Optional alias for the added column If no alias is provided, the clause is used as a column alias This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias)

Return Value

ModelCriteria The current object, for fluid interface

at line 709
public ModelCriteria useQuery($relationName, $secondaryCriteriaClass = null)

Initializes a secondary ModelCriteria object, to be later merged with the current object

Parameters

$relationName
$secondaryCriteriaClass

Return Value

ModelCriteria The secondary criteria object

See also

ModelCriteria::endUse()

at line 738
public ModelCriteria endUse()

Finalizes a secondary criteria and merges it with its primary Criteria

Return Value

ModelCriteria The primary criteria object

See also

Criteria::mergeWith()

at line 761
public ModelCriteria mergeWith(Criteria $criteria, string $operator = null)

Add the content of a Criteria to the current Criteria In case of conflict, the current Criteria keeps its properties

Parameters

Criteria $criteria The criteria to read properties from
string $operator The logical operator used to combine conditions Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR

Return Value

ModelCriteria The primary criteria object

See also

Criteria::mergeWith()

at line 779
public ModelCriteria clear()

Clear the conditions to allow the reuse of the query object.

The ModelCriteria's Model and alias 'all the properties set by construct) will remain.

Return Value

ModelCriteria The primary criteria object

at line 795
public setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin)

Sets the primary Criteria for this secondary Criteria

Parameters

ModelCriteria $criteria The primary criteria
Join $previousJoin The previousJoin for this ModelCriteria

at line 806
public ModelCriteria getPrimaryCriteria()

Gets the primary criteria for this secondary Criteria

Return Value

ModelCriteria The primary criteria

at line 822
public ModelCriteria addSelectQuery(Criteria $subQueryCriteria, string $alias = null, boolean $addAliasAndSelectColumns = true)

Adds a Criteria as subQuery in the From Clause.

Parameters

Criteria $subQueryCriteria Criteria to build the subquery from
string $alias alias for the subQuery
boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns

Return Value

ModelCriteria The current object, for fluid interface

See also

Criteria::addSelectQuery()

at line 849
public ModelCriteria addSelfSelectColumns()

Adds the select columns for a the current table

Return Value

ModelCriteria The current object, for fluid interface

at line 863
public ModelCriteria addRelationSelectColumns(string $relation)

Adds the select columns for a relation

Parameters

string $relation The relation name or alias, as defined in join()

Return Value

ModelCriteria The current object, for fluid interface

at line 880
static public array getClassAndAlias(string $class)

Returns the class and alias of a string representing a model or a relation e.g.

'Book b' => array('Book', 'b')
e.g. 'Book' => array('Book', null)

Parameters

string $class The classname to explode

Return Value

array list($className, $aliasName)

at line 901
static public string getRelationName(string $relation)

Returns the name of a relation from a string.

The input looks like '$leftName.$relationName $relationAlias'

Parameters

string $relation Relation to use for the join

Return Value

string the relationName used in the join

at line 926
public ModelCriteria keepQuery(boolean $isKeepQuery = true)

Triggers the automated cloning on termination.

By default, termination methods don't clone the current object,
even though they modify it. If the query must be reused after termination,
you must call this method prior to termination.

Parameters

boolean $isKeepQuery

Return Value

ModelCriteria The current object, for fluid interface

at line 938
public boolean isKeepQuery()

Checks whether the automated cloning on termination is enabled.

Return Value

boolean true if cloning must be done before termination

at line 966
public ObjectCollection|array|mixed find(ConnectionInterface $con = null)

Issue a SELECT query based on the current ModelCriteria and format the list of results with the current formatter By default, returns an array of model objects

Parameters

ConnectionInterface $con an optional connection object

Return Value

ObjectCollection|array|mixed the list of results, formatted by the current formatter

at line 990
public mixed findOne(ConnectionInterface $con = null)

Issue a SELECT ...

LIMIT 1 query based on the current ModelCriteria
and format the result with the current formatter
By default, returns a model object

Parameters

ConnectionInterface $con an optional connection object

Return Value

mixed the result, formatted by the current formatter

at line 1018
public mixed findOneOrCreate(ConnectionInterface $con = null)

Issue a SELECT ...

LIMIT 1 query based on the current ModelCriteria
and format the result with the current formatter
By default, returns a model object

Parameters

ConnectionInterface $con an optional connection object

Return Value

mixed the result, formatted by the current formatter

Exceptions

PropelException

at line 1050
public mixed findPk(mixed $key, ConnectionInterface $con = null)

Find object by primary key Behaves differently if the model has simple or composite primary key <code> // simple primary key $book = $c->findPk(12, $con); // composite primary key $bookOpinion = $c->findPk(array(34, 634), $con); </code>

Parameters

mixed $key Primary key to use for the query
ConnectionInterface $con an optional connection object

Return Value

mixed the result, formatted by the current formatter

at line 1092
public mixed findPks(array $keys, ConnectionInterface $con = null)

Find objects by primary key Behaves differently if the model has simple or composite primary key <code> // simple primary key $books = $c->findPks(array(12, 56, 832), $con); // composite primary key $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); </code>

Parameters

array $keys Primary keys to use for the query
ConnectionInterface $con an optional connection object

Return Value

mixed the list of results, formatted by the current formatter

Exceptions

PropelException

at line 1126
public mixed findBy(string $column, mixed $value, ConnectionInterface $con = null)

Apply a condition on a column and issues the SELECT query

Parameters

string $column A string representing the column phpName, e.g. 'AuthorId'
mixed $value A value for the condition
ConnectionInterface $con An optional connection object

Return Value

mixed the list of results, formatted by the current formatter

See also

filterBy()
find()

at line 1151
public mixed findByArray(mixed $conditions, ConnectionInterface $con = null)

Apply a list of conditions on columns and issues the SELECT query <code> $c->findByArray(array( 'Title' => 'War And Peace', 'Publisher' => $publisher ), $con); </code>

Parameters

mixed $conditions An array of conditions, using column phpNames as key
ConnectionInterface $con an optional connection object

Return Value

mixed the list of results, formatted by the current formatter

See also

filterByArray()
find()

at line 1170
public mixed findOneBy(mixed $column, mixed $value, ConnectionInterface $con = null)

Apply a condition on a column and issues the SELECT ...

LIMIT 1 query

Parameters

mixed $column A string representing thecolumn phpName, e.g. 'AuthorId'
mixed $value A value for the condition
ConnectionInterface $con an optional connection object

Return Value

mixed the result, formatted by the current formatter

See also

filterBy()
findOne()

at line 1195
public mixed findOneByArray(mixed $conditions, ConnectionInterface $con = null)

Apply a list of conditions on columns and issues the SELECT ...

LIMIT 1 query
<code>
$c->findOneByArray(array(
'Title' => 'War And Peace',
'Publisher' => $publisher
), $con);
</code>

Parameters

mixed $conditions An array of conditions, using column phpNames as key
ConnectionInterface $con an optional connection object

Return Value

mixed the list of results, formatted by the current formatter

See also

filterByArray()
findOne()

at line 1209
public integer count(ConnectionInterface $con = null)

Issue a SELECT COUNT(*) query based on the current ModelCriteria

Parameters

ConnectionInterface $con an optional connection object

Return Value

integer the number of results

at line 1236
public doCount($con = null)

Parameters

$con

at line 1259
public PropelModelPager paginate(int $page = 1, int $maxPerPage = 10, ConnectionInterface $con = null)

Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit.

Parameters

int $page number of the page to start the pager on. Page 1 means no offset
int $maxPerPage maximum number of results per page. Determines the limit
ConnectionInterface $con an optional connection object

Return Value

PropelModelPager a pager object, supporting iteration

at line 1308
public integer delete(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria An optional hook on basePreDelete() can prevent the actual deletion

Parameters

ConnectionInterface $con an optional connection object

Return Value

integer the number of deleted rows

Exceptions

PropelException

at line 1346
public integer deleteAll(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria deleting all rows in the table An optional hook on basePreDelete() can prevent the actual deletion

Parameters

ConnectionInterface $con an optional connection object

Return Value

integer the number of deleted rows

Exceptions

PropelException

at line 1376
public integer doDeleteAll(ConnectionInterface $con = null)

Issue a DELETE query based on the current ModelCriteria deleting all rows in the table This method is called by ModelCriteria::deleteAll() inside a transaction

Parameters

ConnectionInterface $con a connection object

Return Value

integer the number of deleted rows

Exceptions

RuntimeException

at line 1459
public integer update(mixed $values, ConnectionInterface $con = null, boolean $forceIndividualSaves = false)

Issue an UPDATE query based the current ModelCriteria and a list of changes.

An optional hook on basePreUpdate() can prevent the actual update.
Beware that behaviors based on hooks in the object's save() method
will only be triggered if you force individual saves, i.e. if you pass true as second argument.

Parameters

mixed $values Associative array of keys and values to replace
ConnectionInterface $con an optional connection object
boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects

Return Value

integer Number of updated rows

Exceptions

PropelException
PropelException

at line 1505
public integer doUpdate(array $values, ConnectionInterface $con, boolean $forceIndividualSaves = false)

Issue an UPDATE query based the current ModelCriteria and a list of changes.

This method is called by ModelCriteria::update() inside a transaction.

Parameters

array $values Associative array of keys and values to replace
ConnectionInterface $con a connection object
boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects

Return Value

integer Number of updated rows

at line 1806
public DataFetcherInterface doSelect($con $con = null)

Builds, binds and executes a SELECT query based on the current object.

Parameters

$con $con A connection object

Return Value

DataFetcherInterface A dataFetcher using the connection, ready to be fetched

Exceptions

PropelException

at line 1823
public configureSelectColumns()

at line 1919
public string getAliasedColName(string $colName)

Changes the table part of a a fully qualified column name if a true model alias exists e.g.

=> 'book.TITLE' => 'b.TITLE'
This is for use as first argument of Criteria::add()

Parameters

string $colName the fully qualified column name, e.g 'book.TITLE' or BookTableMap::TITLE

Return Value

string the fully qualified column name, using table alias if applicable

at line 1935
static public string getShortName(string $fullyQualifiedClassName)

Return the short ClassName for class with namespace

Parameters

string $fullyQualifiedClassName The fully qualified class name

Return Value

string The short class name

at line 1952
public ModelCriteria addUsingAlias($p1, $value = null, $operator = null)

Overrides Criteria::add() to force the use of a true table alias if it exists

Parameters

$p1
$value
$operator

Return Value

ModelCriteria A modified Criteria object.

See also

Criteria::add()

at line 1964
public array getParams()

Get all the parameters to bind to this criteria Does part of the job of createSelectSql() for the cache

Return Value

array list of parameters, each parameter being an array like array('table' => $realtable, 'column' => $column, 'value' => $value)

at line 2007
public __call($name, $arguments)

Handle the magic Supports findByXXX(), findOneByXXX(), filterByXXX(), orderByXXX(), and groupByXXX() methods, where XXX is a column phpName.

Supports XXXJoin(), where XXX is a join direction (in 'left', 'right', 'inner')

Parameters

$name
$arguments

at line 2068
public __clone()

Ensures deep cloning of attached objects

at line 53
ModelCriteria leftJoin($relation)

Adds a LEFT JOIN clause to the query

Parameters

$relation

Return Value

ModelCriteria

at line 53
ModelCriteria rightJoin($relation)

Adds a RIGHT JOIN clause to the query

Parameters

$relation

Return Value

ModelCriteria

at line 53
ModelCriteria innerJoin($relation)

Adds a INNER JOIN clause to the query

Parameters

$relation

Return Value

ModelCriteria