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: 816 $

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: 816 $


[ Top ]


Class Methods


method add [line 555]

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 274]

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 996]

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 773]

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 236]

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 785]

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 761]

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 961]

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 581]

Criteria addJoin( string $left, string $right, [string $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:

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

[ Top ]

method addOr [line 1052]

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 718]

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 201]

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 817]

Criteria clearGroupByColumns( )

Clear the group-by columns.



Tags:

access:  public


[ Top ]

method clearOrderByColumns [line 806]

Criteria clearOrderByColumns( )

Clear the order-by columns.



Tags:

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


[ Top ]

method clearSelectColumns [line 740]

Criteria clearSelectColumns( )

Clears current select columns.



Tags:

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


[ Top ]

method containsKey [line 307]

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 ]

method equals [line 904]

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 468]

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 248]

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 259]

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 372]

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 404]

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 343]

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 417]

string getDbName( )

Get the Database(Map) name.



Tags:

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


[ Top ]

method getGroupByColumns [line 828]

array getGroupByColumns( )

Get group by columns.



Tags:

access:  public


[ Top ]

method getHaving [line 838]

Criterion getHaving( )

Get Having Criterion.



Tags:

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


[ Top ]

method getIterator [line 181]

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 591]

array getJoins( )

Get the array of Joins.



Tags:

return:  Join[]
access:  public


[ Top ]

method getLimit [line 684]

int getLimit( )

Get limit.



Tags:

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


[ Top ]

method getMap [line 190]

array getMap( )

Get the criteria map.



Tags:

access:  public


[ Top ]

method getNewCriterion [line 361]

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 707]

An getOffset( )

Get offset.



Tags:

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


[ Top ]

method getOrderByColumns [line 796]

array getOrderByColumns( )

Get order by columns.



Tags:

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


[ Top ]

method getSelectColumns [line 730]

array getSelectColumns( )

Get select columns.



Tags:

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


[ Top ]

method getSelectModifiers [line 750]

An getSelectModifiers( )

Get select modifiers.



Tags:

return:  array with the select modifiers.
access:  public


[ Top ]

method getTableForAlias [line 285]

string getTableForAlias( string $alias)

Returns the table name associated with an alias.



Tags:

access:  public


Parameters:

string   $alias  

[ Top ]

method getTableName [line 440]

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 384]

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 454]

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 isIgnoreCase [line 633]

boolean isIgnoreCase( )

Is ignore case on or off?



Tags:

return:  True if case is ignored.
access:  public


[ Top ]

method isSingleRecord [line 661]

boolean isSingleRecord( )

Is single record?



Tags:

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


[ Top ]

method isUseTransaction [line 332]

boolean isUseTransaction( )

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



Tags:

access:  public


[ Top ]

method keys [line 296]

array keys( )

Get the keys for the criteria map.



Tags:

access:  public


[ Top ]

method put [line 487]

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 502]

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 849]

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 ]

constructor __construct [line 171]

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 setAll [line 600]

Criteria setAll( )

Adds "ALL" modifier to the SQL statement.



Tags:

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


[ Top ]

method setDbName [line 429]

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 610]

Criteria setDistinct( )

Adds "DISTINCT" modifier to the SQL statement.



Tags:

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


[ Top ]

method setIgnoreCase [line 622]

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 672]

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 696]

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 setSingleRecord [line 650]

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 321]

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 894]

int size( )

Returns the size (count) of this criteria.



Tags:

access:  public


[ Top ]

method toString [line 866]

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 86]

Comparison type.


[ Top ]

ALT_NOT_EQUAL =  "!="

[line 47]

Comparison type.


[ Top ]

ASC =  "ASC"

[line 98]

"Order by" qualifier - ascending


[ Top ]

BINARY_AND =  "&"

[line 92]

Binary math operator: AND


[ Top ]

BINARY_OR =  "|"

[line 95]

Binary math operator: OR


[ Top ]

CURRENT_DATE =  "CURRENT_DATE"

[line 110]

"CURRENT_DATE" ANSI SQL function


[ Top ]

CURRENT_TIME =  "CURRENT_TIME"

[line 113]

"CURRENT_TIME" ANSI SQL function


[ Top ]

CURRENT_TIMESTAMP =  "CURRENT_TIMESTAMP"

[line 116]

"CURRENT_TIMESTAMP" ANSI SQL function


[ Top ]

CUSTOM =  "CUSTOM"

[line 74]

Comparison type.


[ Top ]

DESC =  "DESC"

[line 101]

"Order by" qualifier - descending


[ Top ]

DISTINCT =  "DISTINCT "

[line 77]

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 80]

Comparison type.


[ Top ]

INNER_JOIN =  "INNER JOIN"

[line 125]

"INNER JOIN" SQL statement


[ Top ]

ISNOTNULL =  " IS NOT NULL "

[line 107]

"IS NOT NULL" null comparison


[ Top ]

ISNULL =  " IS NULL "

[line 104]

"IS NULL" null comparison


[ Top ]

JOIN =  "JOIN"

[line 89]

Comparison type.


[ Top ]

LEFT_JOIN =  "LEFT JOIN"

[line 119]

"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 83]

Comparison type.


[ Top ]

NOT_LIKE =  " NOT LIKE "

[line 65]

Comparison type.


[ Top ]

RIGHT_JOIN =  "RIGHT JOIN"

[line 122]

"RIGHT JOIN" SQL statement


[ Top ]



Documentation generated on Thu, 22 Nov 2007 03:33:37 +0000 by phpDocumentor 1.4.0