propel-util
[ class tree: propel-util ] [ index: propel-util ] [ all elements ]

Class: Criteria

Source Location: /util/Criteria.php

Class Overview


This is a utility class for holding criteria information for a query.


Author(s):

Version:

  • $Revision: 1262 $

Implements interfaces:

  • IteratorAggregate (internal interface)

Constants

Methods



Class Details

[line 38]
This is a utility class for holding criteria information for a query.

BasePeer constructs SQL statements based on the values in this class.




Tags:

author:  Frank Y. Kim <frank.kim@clearink.com> (Torque)
author:  Kaspars Jaudzems <kaspars.jaudzems@inbox.lv> (Propel)
author:  Hans Lellelid <hans@xmpl.org> (Propel)
author:  Sam Joseph <sam@neurogrid.com> (Torque)
author:  John D. McNally <jmcnally@collab.net> (Torque)
author:  Henning P. Schmiedehausen <hps@intermeta.de> (Torque)
author:  Eric Dobbs <eric@dobbse.net> (Torque)
author:  Brett McLaughlin <bmclaugh@algx.net> (Torque)
version:  $Revision: 1262 $


[ Top ]


Class Methods


method add [line 607]

A add( $p1, [mixed $value = null], [string $comparison = null], string $critOrColumn)

This method adds a new criterion to the list of criterias.

If a criterion for the requested column already exists, it is replaced. If is used as follow:

<p>

  1.  $crit new Criteria();
  2.  $crit->add(&quot;column&quot;,
  3.                                       &quot;value&quot;
  4.                                       &quot;Criteria::GREATER_THAN&quot;);

Any comparison can be used.

The name of the table must be used implicitly in the column name, so the Column name must be something like 'TABLE.id'. If you don't like this, you can use the add(table, column, value) method.




Tags:

return:  modified Criteria object.
access:  public


Parameters:

string   $critOrColumn   The column to run the comparison on, or Criterion object.
mixed   $value  
string   $comparison   A String.
   $p1  

[ Top ]

method addAlias [line 285]

void addAlias( string $alias, string $table)

Allows one to specify an alias for a table that can be used in various parts of the SQL.



Tags:

access:  public


Parameters:

string   $alias  
string   $table  

[ Top ]

method addAnd [line 1122]

Criteria addAnd( $p1, [ $p2 = null], [ $p3 = null])

This method adds a new criterion to the list of criterias.

If a criterion for the requested column already exists, it is "AND"ed to the existing criterion.

addAnd(column, value, comparison)

  1.  $crit $orig_crit->addAnd(&quot;column&quot;,
  2.                                       &quot;value&quot;
  3.                                       &quot;Criterion::GREATER_THAN&quot;);

addAnd(column, value)

  1.  $crit $orig_crit->addAnd(&quot;column&quot;&quot;value&quot;);

addAnd(Criterion)

  1.  $crit new Criteria();
  2.  $c $crit->getNewCriterion(BasePeer::ID5Criteria::LESS_THAN);
  3.  $crit->addAnd($c);

Any comparison can be used, of course.




Tags:

return:  A modified Criteria object.
access:  public


Parameters:

   $p1  
   $p2  
   $p3  

[ Top ]

method addAscendingOrderByColumn [line 898]

A addAscendingOrderByColumn( name $name)

Add order by column name, explicitly specifying ascending.



Tags:

return:  modified Criteria object.
access:  public


Parameters:

name   $name   The name of the column to order by.

[ Top ]

method addAsColumn [line 247]

Criteria addAsColumn( string $name, string $clause)

Add an AS clause to the select columns. Usage:

  1.  Criteria myCrit new Criteria();
  2.  myCrit->addAsColumn("alias""ALIAS(".MyPeer::ID.")");




Tags:

return:  A modified Criteria object.
access:  public


Parameters:

string   $name   Wanted Name of the column (alias).
string   $clause  

SQL clause to select from the table

If the name already exists, it is replaced by the new clause.


[ Top ]

method addDescendingOrderByColumn [line 910]

Criteria addDescendingOrderByColumn( string $name)

Add order by column name, explicitly specifying descending.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

string   $name   The name of the column to order by.

[ Top ]

method addGroupByColumn [line 886]

A addGroupByColumn( string $groupBy)

Add group by column name.



Tags:

return:  modified Criteria object.
access:  public


Parameters:

string   $groupBy   The name of the column to group by.

[ Top ]

method addHaving [line 1087]

A addHaving( Criterion $having)

This method adds a prepared Criterion object to the Criteria as a having clause.

You can get a new, empty Criterion object with the getNewCriterion() method.

<p>

  1.  $crit new Criteria();
  2.  $c $crit->getNewCriterion(BasePeer::ID5Criteria::LESS_THAN);
  3.  $crit->addHaving($c);




Tags:

return:  modified Criteria object.
access:  public


Parameters:

having   $having   A Criterion object

[ Top ]

method addJoin [line 634]

Criteria addJoin( mixed $left, mixed $right, [mixed $operator = null])

This is the way that you should add a straight (inner) join of two tables. For example:

AND PROJECT.PROJECT_ID=FOO.PROJECT_ID

left = PROJECT.PROJECT_ID right = FOO.PROJECT_ID




Tags:

return:  A modified Criteria object.
access:  public


Parameters:

mixed   $left   A String with the left side of the join.
mixed   $right   A String with the right side of the join.
mixed   $operator   A String with the join operator e.g. LEFT JOIN, ...

[ Top ]

method addJoinObject [line 689]

Criteria addJoinObject( Join $join)

Add a join object to the Criteria



Tags:

return:  A modified Criteria object
access:  public


Parameters:

Join   $join   A join object

[ Top ]

method addMultipleJoin [line 671]

Criteria addMultipleJoin( array $conditions, [string $joinType = null])

Add a join with multiple conditions see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606

Example usage: $c->addMultipleJoin(array( array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL ) ), Criteria::LEFT_JOIN );




Tags:

return:  A modified Criteria object.
see:  Criteria::addJoin()
access:  public


Parameters:

array   $conditions   An array of conditions, each condition being an array (left, right, operator)
string   $joinType   A String with the join operator. Defaults to an implicit join.

[ Top ]

method addOr [line 1178]

Criteria addOr( $p1, [ $p2 = null], [ $p3 = null])

This method adds a new criterion to the list of criterias.

If a criterion for the requested column already exists, it is "OR"ed to the existing criterion.

Any comparison can be used.

Supports a number of different signatures:

addOr(column, value, comparison)

  1.  $crit $orig_crit->addOr(&quot;column&quot;,
  2.                                       &quot;value&quot;
  3.                                       &quot;Criterion::GREATER_THAN&quot;);

addOr(column, value)

  1.  $crit $orig_crit->addOr(&quot;column&quot;&quot;value&quot;);

addOr(Criterion)




Tags:

return:  A modified Criteria object.
access:  public


Parameters:

   $p1  
   $p2  
   $p3  

[ Top ]

method addSelectColumn [line 829]

Criteria addSelectColumn( string $name)

Add select column.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

string   $name   Name of the select column.

[ Top ]

method clear [line 212]

void clear( )

Brings this criteria back to its initial state, so that it can be reused as if it was new. Except if the criteria has grown in capacity, it is left at the current capacity.



Tags:

access:  public


[ Top ]

method clearGroupByColumns [line 942]

Criteria clearGroupByColumns( )

Clear the group-by columns.



Tags:

access:  public


[ Top ]

method clearOrderByColumns [line 931]

Criteria clearOrderByColumns( )

Clear the order-by columns.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


[ Top ]

method clearSelectColumns [line 865]

Criteria clearSelectColumns( )

Clears current select columns.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


[ Top ]

method containsKey [line 318]

boolean containsKey( string $column)

Does this Criteria object contain the specified key?



Tags:

return:  True if this Criteria object contain the specified key.
access:  public


Parameters:

string   $column   [table.]column

[ Top ]

constructor __construct [line 182]

Criteria __construct( [dbName $dbName = null])

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



Tags:

access:  public


Parameters:

dbName   $dbName   The dabase name.

[ Top ]

method equals [line 1029]

boolean equals( $crit)

This method checks another Criteria to see if they contain the same attributes and hashtable entries.



Tags:

access:  public


Parameters:

   $crit  

[ Top ]

method get [line 520]

mixed get( string $key)

An alias to getValue() -- exposing a Hashtable-like interface.



Tags:

return:  The value within the Criterion (not the Criterion object).
access:  public


Parameters:

string   $key   An Object.

[ Top ]

method getAsColumns [line 259]

array getAsColumns( )

Get the column aliases.



Tags:

return:  An assoc array which map the column alias names to the alias clauses.
access:  public


[ Top ]

method getColumnForAs [line 270]

string getColumnForAs( $as, string $alias)

Returns the column name associated with an alias (AS-column).



Tags:

access:  public


Parameters:

string   $alias  
   $as  

[ Top ]

method getColumnName [line 396]

string getColumnName( string $name)

Method to return a String table name.



Tags:

return:  The value of the object at key.
access:  public


Parameters:

string   $name   Name of the key.

[ Top ]

method getComparison [line 428]

string getComparison( string $key)

Method to return a comparison String.



Tags:

return:  A String with the value of the object at key.
access:  public


Parameters:

string   $key   String name of the key.

[ Top ]

method getCriterion [line 367]

Criterion getCriterion( string $column)

Method to return criteria related to columns in a table.



Tags:

return:  A Criterion or null if $column is invalid.
access:  public


Parameters:

string   $column   Column name.

[ Top ]

method getDbName [line 441]

string getDbName( )

Get the Database(Map) name.



Tags:

return:  A String with the Database(Map) name.
access:  public


[ Top ]

method getGroupByColumns [line 953]

array getGroupByColumns( )

Get group by columns.



Tags:

access:  public


[ Top ]

method getHaving [line 963]

Criterion getHaving( )

Get Having Criterion.



Tags:

return:  A Criterion object that is the having clause.
access:  public


[ Top ]

method getIterator [line 192]

void getIterator( )

Implementing SPL IteratorAggregate interface. This allows you to foreach () over a Criteria object.



Tags:

access:  public



Implementation of:
IteratorAggregate::getIterator
[ Top ]

method getJoins [line 702]

array getJoins( )

Get the array of Joins.



Tags:

return:  Join[]
access:  public


[ Top ]

method getLimit [line 795]

int getLimit( )

Get limit.



Tags:

return:  An int with the value for limit.
access:  public


[ Top ]

method getMap [line 201]

array getMap( )

Get the criteria map.



Tags:

access:  public


[ Top ]

method getNewCriterion [line 385]

Criterion getNewCriterion( string $column, mixed $value, [string $comparison = null])

Method to return criterion that is not added automatically to this Criteria. This can be used to chain the Criterions to form a more complex where clause.



Tags:

access:  public


Parameters:

string   $column   Full name of column (for example TABLE.COLUMN).
mixed   $value  
string   $comparison  

[ Top ]

method getOffset [line 818]

An getOffset( )

Get offset.



Tags:

return:  int with the value for offset.
access:  public


[ Top ]

method getOrderByColumns [line 921]

array getOrderByColumns( )

Get order by columns.



Tags:

return:  An array with the name of the order columns.
access:  public


[ Top ]

method getPrimaryTableName [line 467]

string getPrimaryTableName( )

Get the primary table for this Criteria.

This is useful for cases where a Criteria may not contain any SELECT columns or WHERE columns. This must be explicitly set, of course, in order to be useful.




Tags:

access:  public


[ Top ]

method getSelectColumns [line 855]

array getSelectColumns( )

Get select columns.



Tags:

return:  An array with the name of the select columns.
access:  public


[ Top ]

method getSelectModifiers [line 875]

An getSelectModifiers( )

Get select modifiers.



Tags:

return:  array with the select modifiers.
access:  public


[ Top ]

method getTableForAlias [line 296]

string getTableForAlias( string $alias)

Returns the table name associated with an alias.



Tags:

access:  public


Parameters:

string   $alias  

[ Top ]

method getTableName [line 492]

string getTableName( string $name)

Method to return a String table name.



Tags:

return:  The value of table for criterion at key.
access:  public


Parameters:

string   $name   The name of the key.

[ Top ]

method getTablesColumns [line 408]

array getTablesColumns( )

Shortcut method to get an array of columns indexed by table.



Tags:

return:  array(table => array(table.column1, table.column2))
access:  public


[ Top ]

method getValue [line 506]

mixed getValue( string $name)

Method to return the value that was added to Criteria.



Tags:

return:  The value of object at key.
access:  public


Parameters:

string   $name   A String with the name of the key.

[ Top ]

method hasSelectClause [line 844]

boolean hasSelectClause( )

Whether this Criteria has any select columns.

This will include columns added with addAsColumn() method.




Tags:

see:  Criteria::addAsColumn()
see:  Criteria::addSelectColumn()
access:  public


[ Top ]

method isIgnoreCase [line 744]

boolean isIgnoreCase( )

Is ignore case on or off?



Tags:

return:  True if case is ignored.
access:  public


[ Top ]

method isSingleRecord [line 772]

boolean isSingleRecord( )

Is single record?



Tags:

return:  True if a single record is being returned.
access:  public


[ Top ]

method isUseTransaction [line 356]

boolean isUseTransaction( )

Whether the sql command specified by this criteria must be wrapped in a transaction.



Tags:

access:  public


[ Top ]

method keyContainsValue [line 331]

boolean keyContainsValue( string $column)

Does this Criteria object contain the specified key and does it have a value set for the key



Tags:

return:  True if this Criteria object contain the specified key and a value for that key
access:  public


Parameters:

string   $column   [table.]column

[ Top ]

method keys [line 307]

array keys( )

Get the keys for the criteria map.



Tags:

access:  public


[ Top ]

method put [line 539]

Instance put( string $key, mixed $value)

Overrides Hashtable put, so that this object is returned instead of the value previously in the Criteria object.

The reason is so that it more closely matches the behavior of the add() methods. If you want to get the previous value then you should first Criteria.get() it yourself. Note, if you attempt to pass in an Object that is not a String, it will throw a NPE. The reason for this is that none of the add() methods support adding anything other than a String as a key.




Tags:

return:  of self.
access:  public


Parameters:

string   $key  
mixed   $value  

[ Top ]

method putAll [line 554]

void putAll( mixed $t)

Copies all of the mappings from the specified Map to this Criteria These mappings will replace any mappings that this Criteria had for any of the keys currently in the specified Map.

if the map was another Criteria, its attributes are copied to this Criteria, overwriting previous settings.




Tags:

access:  public


Parameters:

mixed   $t   Mappings to be stored in this map.

[ Top ]

method remove [line 974]

mixed remove( string $key)

Remove an object from the criteria.



Tags:

return:  The removed value.
access:  public


Parameters:

string   $key   A string with the key to be removed.

[ Top ]

method setAll [line 711]

Criteria setAll( )

Adds "ALL" modifier to the SQL statement.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


[ Top ]

method setDbName [line 453]

void setDbName( [string $dbName = null])

Set the DatabaseMap name. If
  1. null
is supplied, uses value provided by
.



Tags:

access:  public


Parameters:

string   $dbName   The Database (Map) name.

[ Top ]

method setDistinct [line 721]

Criteria setDistinct( )

Adds "DISTINCT" modifier to the SQL statement.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


[ Top ]

method setIgnoreCase [line 733]

Criteria setIgnoreCase( boolean $b)

Sets ignore case.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

boolean   $b   True if case should be ignored.

[ Top ]

method setLimit [line 783]

Criteria setLimit( limit $limit)

Set limit.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

limit   $limit   An int with the value for limit.

[ Top ]

method setOffset [line 807]

Criteria setOffset( int $offset)

Set offset.



Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

int   $offset   An int with the value for offset. (Note this values is cast to a 32bit integer and may result in truncatation)

[ Top ]

method setPrimaryTableName [line 481]

void setPrimaryTableName( $tableName, string $v)

Sets the primary table for this Criteria.

This is useful for cases where a Criteria may not contain any SELECT columns or WHERE columns. This must be explicitly set, of course, in order to be useful.




Tags:

access:  public


Parameters:

string   $v  
   $tableName  

[ Top ]

method setSingleRecord [line 761]

Criteria setSingleRecord( boolean $b)

Set single record? Set this to
  1. true
if you expect the query

to result in only a single result record (the default behaviour is to throw a PropelException if multiple records are returned when the query is executed). This should be used in situations where returning multiple rows would indicate an error of some sort. If your query might return multiple records but you are only interested in the first one then you should be using setLimit(1).




Tags:

return:  Modified Criteria object (for fluent API)
access:  public


Parameters:

boolean   $b   Set to TRUE if you expect the query to select just one record.

[ Top ]

method setUseTransaction [line 345]

void setUseTransaction( $v)

Will force the sql represented by this criteria to be executed within a transaction. This is here primarily to support the oid type in postgresql. Though it can be used to require any single sql statement to use a transaction.



Tags:

access:  public


Parameters:

   $v  

[ Top ]

method size [line 1019]

int size( )

Returns the size (count) of this criteria.



Tags:

access:  public


[ Top ]

method toString [line 991]

string toString( )

Build a string representation of the Criteria.



Tags:

return:  A String with the representation of the Criteria.
access:  public


[ Top ]


Class Constants

ALL =  "ALL "

[line 89]

Comparison type.


[ Top ]

ALT_NOT_EQUAL =  "!="

[line 47]

Comparison type.


[ Top ]

ASC =  "ASC"

[line 101]

"Order by" qualifier - ascending


[ Top ]

BINARY_AND =  "&"

[line 95]

Binary math operator: AND


[ Top ]

BINARY_OR =  "|"

[line 98]

Binary math operator: OR


[ Top ]

CURRENT_DATE =  "CURRENT_DATE"

[line 113]

"CURRENT_DATE" ANSI SQL function


[ Top ]

CURRENT_TIME =  "CURRENT_TIME"

[line 116]

"CURRENT_TIME" ANSI SQL function


[ Top ]

CURRENT_TIMESTAMP =  "CURRENT_TIMESTAMP"

[line 119]

"CURRENT_TIMESTAMP" ANSI SQL function


[ Top ]

CUSTOM =  "CUSTOM"

[line 74]

Comparison type.


[ Top ]

CUSTOM_EQUAL =  "CUSTOM_EQUAL"

[line 77]

Comparison type for update


[ Top ]

DESC =  "DESC"

[line 104]

"Order by" qualifier - descending


[ Top ]

DISTINCT =  "DISTINCT "

[line 80]

Comparison type.


[ Top ]

EQUAL =  "="

[line 41]

Comparison type.


[ Top ]

GREATER_EQUAL =  ">="

[line 56]

Comparison type.


[ Top ]

GREATER_THAN =  ">"

[line 50]

Comparison type.


[ Top ]

ILIKE =  " ILIKE "

[line 68]

PostgreSQL comparison type


[ Top ]

IN =  " IN "

[line 83]

Comparison type.


[ Top ]

INNER_JOIN =  "INNER JOIN"

[line 128]

"INNER JOIN" SQL statement


[ Top ]

ISNOTNULL =  " IS NOT NULL "

[line 110]

"IS NOT NULL" null comparison


[ Top ]

ISNULL =  " IS NULL "

[line 107]

"IS NULL" null comparison


[ Top ]

JOIN =  "JOIN"

[line 92]

Comparison type.


[ Top ]

LEFT_JOIN =  "LEFT JOIN"

[line 122]

"LEFT JOIN" SQL statement


[ Top ]

LESS_EQUAL =  "<="

[line 59]

Comparison type.


[ Top ]

LESS_THAN =  "<"

[line 53]

Comparison type.


[ Top ]

LIKE =  " LIKE "

[line 62]

Comparison type.


[ Top ]

NOT_EQUAL =  "<>"

[line 44]

Comparison type.


[ Top ]

NOT_ILIKE =  " NOT ILIKE "

[line 71]

PostgreSQL comparison type


[ Top ]

NOT_IN =  " NOT IN "

[line 86]

Comparison type.


[ Top ]

NOT_LIKE =  " NOT LIKE "

[line 65]

Comparison type.


[ Top ]

RIGHT_JOIN =  "RIGHT JOIN"

[line 125]

"RIGHT JOIN" SQL statement


[ Top ]



Documentation generated on Tue, 12 Jan 2010 23:07:58 +0000 by phpDocumentor 1.4.3