pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Selection Class Reference

Selection of records in database. More...

Inheritance diagram for Selection:
BaseObject Relation

Public Member Functions

 rewind ()
 Iterator.rewind() implementation. More...
 
 current ()
 Iterator.current() implementation. More...
 
 key ()
 Iterator.key() implementation. More...
 
 next ()
 Iterator.next() implementation. More...
 
 valid ()
 Iterator.valid() implementation. More...
 
 __call ($name, $args)
 PHP magic method. More...
 
 first ()
 Return first record in the selection. More...
 
 isEmpty ()
 Is Selection empty? More...
 
 count ()
 Return number of rows in the Selection.
 
 sum ($s)
 Return summary of field $s. More...
 
 avg ($s)
 Return AVG of field $s. More...
 
 find ($id)
 Find record by primary key. More...
 
 update (array $values)
 Update records in selection with $values.
 
 delete ()
 Delete selection.
 
 getClone ()
 Clone selection.
 
 limit ($limit, $offset=0)
 Set selection limit. More...
 
 select ($columns)
 Execute selection and return array of rows. More...
 
 from ($s)
 Set source table $s. More...
 
 where ($s)
 Set where condition. More...
 
 whereJoin ($relName, $s)
 Set where condition. More...
 
 order ($s)
 Set order by clausule. More...
 
 group ($s)
 Set group by clausule. More...
 
 having ($s)
 Set having clausule. More...
 
 close ()
 Closes the cursor, enabling the query to be executed again. More...
 
 clear ()
 Clear selection query and data. More...
 
 getSql ()
 Build sql query for current selection. More...
 
 toArray ()
 Return current selection as array. More...
 
 __toString ()
 Return string representation of selection for debugging purposes.
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 addEvent ($name, $callback)
 Add event handler to $object->$name property. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $db
 var Db
 
- Data Fields inherited from BaseObject
 $onNewInstance
 Occurs when new instance of the class is created. More...
 
 $onMissingMethod
 Occurs when called method does not exist. More...
 
 $serviceLocator
 var function() Return service object when requested with service(). More...
 

Protected Member Functions

 newModel ($data)
 Create model instance, fill its values with $data and return it. More...
 
 execute ()
 Execute query to the database and set $this->result. More...
 
- Protected Member Functions inherited from BaseObject
 fireEvent ($name, array $args=array())
 Run all event handlers in $object->$name property. More...
 
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Protected Attributes

 $query = array()
 Array of sql query clausules. More...
 
 $result = null
 Result of underlying sql query. More...
 
 $data = array()
 Data of the current row. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 

Detailed Description

Selection of records in database.

It represents any selection on database table and will return Model instances as records. It does not load records from the database before they are really requested.

Features:

Member Function Documentation

__call (   $name,
  $args 
)

PHP magic method.

Redirect unknown method call to underlying model class.

avg (   $s)

Return AVG of field $s.

: verify if $s is valid fieldname.

clear ( )

Clear selection query and data.

Returns
Selection $this
close ( )

Closes the cursor, enabling the query to be executed again.

Returns
Selection $this
current ( )

Iterator.current() implementation.

execute ( )
protected

Execute query to the database and set $this->result.

Returns
$result
find (   $id)

Find record by primary key.

Returns
Model $model
first ( )

Return first record in the selection.

Returns
Model $model
from (   $s)

Set source table $s.

Fluent interface.

Returns
Selection $this
getSql ( )

Build sql query for current selection.

Returns
string $sql
group (   $s)

Set group by clausule.

Fluent interface.

Returns
Selection $this
having (   $s)

Set having clausule.

Fluent interface.

Returns
Selection $this
isEmpty ( )

Is Selection empty?

Returns
bool $isEmpty
key ( )

Iterator.key() implementation.

limit (   $limit,
  $offset = 0 
)

Set selection limit.

Fluent interface.

Returns
Selection $this
newModel (   $data)
protected

Create model instance, fill its values with $data and return it.

Returns
Model $model
next ( )

Iterator.next() implementation.

order (   $s)

Set order by clausule.

Fluent interface.

Returns
Selection $this
rewind ( )

Iterator.rewind() implementation.

select (   $columns)

Execute selection and return array of rows.

Parameters
array | string$columnsList of columns to select
Returns
array $rows
sum (   $s)

Return summary of field $s.

: verify if $s is valid fieldname.

toArray ( )

Return current selection as array.

Returns
array $rows Array of models.
valid ( )

Iterator.valid() implementation.

where (   $s)

Set where condition.

Fluent interface.

Returns
Selection $this
whereJoin (   $relName,
  $s 
)

Set where condition.

Fluent interface.

Parameters
$relNameName of relation
$sCondition used on relation
Returns
Selection $this

Field Documentation

$data = array()
protected

Data of the current row.

$query = array()
protected

Array of sql query clausules.

$result = null
protected

Result of underlying sql query.


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