PHP Class phpDataMapper_Query, phpDataMapper

Author: Vance Lucas ([email protected])
Inheritance: implements Countable, implements IteratorAggregate
显示文件 Open project: vlucas/phpDataMapper Class Usage Examples

Public Properties

Property Type Description
$conditions
$fields Storage for query properties
$group
$limit
$limitOffset
$order
$source

Protected Properties

Property Type Description
$_mapper

Public Methods

Method Description
__construct ( phpDataMapper_Base $mapper ) Constructor Method
all ( array $conditions = [] ) Find records with given conditions If all parameters are empty, find all records
andWhere ( array $conditions = [], $type = "AND" )
count ( ) : integer SPL Countable function Called automatically when attribute is used in a 'count()' function call
execute ( ) : mixed Execute and return query as a collection
first ( ) : mixed Return the first entity matched by the query
from ( string $source = null ) From
getIterator ( ) : phpDataMapper_Query_Set SPL IteratorAggregate function Called automatically when attribute is used in a 'foreach' loop
group ( array $fields = [] ) GROUP BY clause
limit ( integer $limit = 20, integer $offset = null ) Limit executed query to specified amount of rows Implemented at adapter-level for databases that support it
mapper ( ) Get current adapter object
orWhere ( array $conditions = [], $type = "AND" )
order ( array $fields = [] ) ORDER BY columns
params ( ) : array Return array of parameters in key => value format
select ( mixed $fields = "*", string $source = null ) : string Called from mapper's select() function
toArray ( $keyColumn = null, $valueColumn = null ) : array Convenience function passthrough for Collection
where ( array $conditions = [], string $type = "AND", string $setType = "AND" ) WHERE conditions

Method Details

__construct() public method

Constructor Method
public __construct ( phpDataMapper_Base $mapper )
$mapper phpDataMapper_Base

all() public method

Find records with given conditions If all parameters are empty, find all records
public all ( array $conditions = [] )
$conditions array Array of conditions in column => value pairs

andWhere() public method

public andWhere ( array $conditions = [], $type = "AND" )
$conditions array

count() public method

SPL Countable function Called automatically when attribute is used in a 'count()' function call
public count ( ) : integer
return integer

execute() public method

Execute and return query as a collection
public execute ( ) : mixed
return mixed Collection object on success, boolean false on failure

first() public method

Return the first entity matched by the query
public first ( ) : mixed
return mixed phpDataMapper_Entity on success, boolean false on failure

from() public method

From
public from ( string $source = null )
$source string Name of the data source to perform a query on

getIterator() public method

SPL IteratorAggregate function Called automatically when attribute is used in a 'foreach' loop
public getIterator ( ) : phpDataMapper_Query_Set
return phpDataMapper_Query_Set

group() public method

GROUP BY clause
public group ( array $fields = [] )
$fields array Array of field names to use for grouping

limit() public method

Limit executed query to specified amount of rows Implemented at adapter-level for databases that support it
public limit ( integer $limit = 20, integer $offset = null )
$limit integer Number of records to return
$offset integer Row to start at for limited result set

mapper() public method

Get current adapter object
public mapper ( )

orWhere() public method

public orWhere ( array $conditions = [], $type = "AND" )
$conditions array

order() public method

ORDER BY columns
public order ( array $fields = [] )
$fields array Array of field names to use for sorting

params() public method

Return array of parameters in key => value format
public params ( ) : array
return array Parameters in key => value format

select() public method

Called from mapper's select() function
public select ( mixed $fields = "*", string $source = null ) : string
$fields mixed (optional)
$source string Data source name
return string

toArray() public method

Convenience function passthrough for Collection
public toArray ( $keyColumn = null, $valueColumn = null ) : array
return array

where() public method

WHERE conditions
public where ( array $conditions = [], string $type = "AND", string $setType = "AND" )
$conditions array Array of conditions for this clause
$type string Keyword that will separate each condition - "AND", "OR"
$setType string Keyword that will separate the whole set of conditions - "AND", "OR"

Property Details

$_mapper protected_oe property

protected $_mapper

$conditions public_oe property

public $conditions

$fields public_oe property

Storage for query properties
public $fields

$group public_oe property

public $group

$limit public_oe property

public $limit

$limitOffset public_oe property

public $limitOffset

$order public_oe property

public $order

$source public_oe property

public $source