.

DBWhereGroup Class Reference
[Model]

A group of where statements that acts as own where. More...

Inheritance diagram for DBWhereGroup:
IDBWhere IDBWhereHolder

List of all members.

Public Member Functions

  __construct (IDBTable $table, $logical_operator=IDBWhere::LOGIC_AND)
  Constructor.
  add_where ($column, $operator=null, $value=null, $mode=IDBWhere::LOGIC_AND)
  Adds where to this.
  add_where_object (IDBWhere $where)
  Adds IDBWhere instance to this.
  count ()
  Returns the number of clauses added.
  get_children ()
  Returns where objcts, this groups consists of, as array.
  get_column ()
  Returns column.
  get_logical_operator ()
  Return logical operator (AND or OR).
  get_operator ()
  Returns the operator (=, >=, LIKe etc.
  get_sql ()
  Return SQL fragment.
  get_table ()
  Returns table assigned.
  get_value ()
  Returns the value.
  get_wheres ()
  Returns root collection of wheres.

Protected Attributes

  $logical_operator
  $table
  $where_clauses = array()

Detailed Description

A group of where statements that acts as own where.

Author:
Gerd Riesselmann

Definition at line 8 of file dbwheregroup.cls.php.


Constructor & Destructor Documentation

DBWhereGroup::__construct ( IDBTable table,
logical_operator = IDBWhere::LOGIC_AND  
)

Constructor.

Parameters:
IDBTable  $table Table that contains column
string  $column Column to query upon, or a full sql where statement
string  $operator Operator to execute
mixed  $value Value(s) to use
string  $logical_operator Either IDBWhere::LOGIC_AND or IDBWhere::LOGIC_OR

Definition at line 27 of file dbwheregroup.cls.php.

00027                                                                                             {
00028                 $this->table = $table;
00029                 $this->logical_operator = $logical_operator;
00030         }

Member Function Documentation

DBWhereGroup::add_where ( column,
operator = null,
value = null,
mode = IDBWhere::LOGIC_AND  
)

Adds where to this.

Example:

$object = new mytable(); $object->add_where('id', '>', 3); $object->add_where('name', 'in', array('Hans', 'Joe')); $wheres = new DBWhereGroup($object); * $wheres->add_where('email', IDBWhere::OP_LIKE, 'provider1'); $wheres->add_where('email', IDBWhere::OP_LIKE, 'provider2', IDBWhere::LOGIC_OR); $object->add_where($wheres->get_sql());

Results in the following SQL: SELECT * FROM mytable WHERE id > 3 AND name IN ('Hans', 'Joe') AND (email LIKE 'provider1' OR email LIKE 'provider2');

Parameters:
string  $column Column to query upon, or a full sql where statement
string  $operator Operator to execute
mixed  $value Value(s) to use
string  $mode Either IDBWhere::LOGIC_AND or IDBWhere::LOGIC_OR
Returns:
DBWhere

Implements IDBWhereHolder.

Definition at line 55 of file dbwheregroup.cls.php.

00055                                                                                                        {
00056                 $ret = new DBWhere($this->table, $column, $operator, $value, $mode);
00057                 $this->where_clauses[] = $ret;
00058                 return $ret;
00059         }
DBWhereGroup::add_where_object ( IDBWhere where  ) 

Adds IDBWhere instance to this.

Implements IDBWhereHolder.

Definition at line 64 of file dbwheregroup.cls.php.

00064                                                           {
00065                 $this->where_clauses[] = $where;        
00066         }
DBWhereGroup::count (  ) 

Returns the number of clauses added.

Returns:
int

Definition at line 82 of file dbwheregroup.cls.php.

00082                                 {
00083                 return count($this->where_clauses);
00084         }
DBWhereGroup::get_children (  ) 

Returns where objcts, this groups consists of, as array.

Returns:
array

Definition at line 91 of file dbwheregroup.cls.php.

00091                                        {
00092                 return $this->where_clauses;
00093         }
DBWhereGroup::get_column (  ) 

Returns column.

May also be null.

Returns:
string

Implements IDBWhere.

Definition at line 120 of file dbwheregroup.cls.php.

00120                                      {
00121                 
00122         }
DBWhereGroup::get_logical_operator (  ) 

Return logical operator (AND or OR).

Returns:
string

Implements IDBWhere.

Definition at line 147 of file dbwheregroup.cls.php.

00147                                                {
00148                 return $this->logical_operator;
00149         }
DBWhereGroup::get_operator (  ) 

Returns the operator (=, >=, LIKe etc.

) May also be NULL

Returns:
string

Implements IDBWhere.

Definition at line 129 of file dbwheregroup.cls.php.

00129                                        {
00130                 return null;
00131         }
DBWhereGroup::get_sql (  ) 

Return SQL fragment.

Returns:
string

Definition at line 100 of file dbwheregroup.cls.php.

00100                                   {
00101                 $builder = DBSqlBuilderFactory::create_builder(DBSqlBuilderFactory::WHEREGROUP, $this);
00102                 return $builder->get_sql();
00103         }
DBWhereGroup::get_table (  ) 

Returns table assigned.

Returns:
IDBTable

Implements IDBWhere.

Definition at line 111 of file dbwheregroup.cls.php.

00111                                     {
00112                 return $this->table;
00113         }
DBWhereGroup::get_value (  ) 

Returns the value.

May also be NULL

Returns:
mixed

Implements IDBWhere.

Definition at line 138 of file dbwheregroup.cls.php.

00138                                     {
00139                 return null;
00140         }
DBWhereGroup::get_wheres (  ) 

Returns root collection of wheres.

Returns:
DBWhereGroup

Implements IDBWhereHolder.

Definition at line 73 of file dbwheregroup.cls.php.

00073                                      {
00074                 return $this;
00075         }       

Member Data Documentation

DBWhereGroup::$logical_operator [protected]

Definition at line 10 of file dbwheregroup.cls.php.

DBWhereGroup::$table [protected]

Definition at line 16 of file dbwheregroup.cls.php.

DBWhereGroup::$where_clauses = array() [protected]

Definition at line 9 of file dbwheregroup.cls.php.


The documentation for this class was generated from the following file: