interface DataMapperInterface (View source)

DataMapper Interface

Methods

mixed
find(mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)

Find records and return data set.

mixed
findAll(mixed $order = null, integer $start = null, integer $limit = null)

Find records without where conditions and return data set.

mixed
findOne(mixed $conditions = array(), mixed $order = null)

Find one record and return a data.

mixed
findColumn(string $column, mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)

Find column as an array.

mixed
create(mixed $dataset)

Create records by data set.

mixed
createOne(mixed $data)

Create one record by data object.

mixed
update(mixed $dataset, array $condFields = null)

Update records by data set. Every data depend on this table's primary key to update itself.

mixed
updateBatch(mixed $data, mixed $conditions = array())

Using one data to update multiple rows, filter by where conditions.

mixed
updateOne(mixed $data, array $condFields = null)

Same as update(), just update one row.

mixed
flush(mixed $dataset, mixed $conditions = array())

Flush records, will delete all by conditions then recreate new.

mixed
save(mixed $dataset, array $condFields = null)

Save will auto detect is conditions matched in data or not.

mixed
saveOne(mixed $data, array $condFields = null)

Save only one row.

boolean
delete(mixed $conditions)

Delete records by where conditions.

Details

at line line 37
mixed find(mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)

Find records and return data set.

Example: - $mapper->find(array('id' => 5), 'date', 20, 10); - $mapper->find(null, 'id', 0, 1);

Parameters

mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'
mixed $order Order sort, can ba string, array or object. Example: - id ASC => ORDER BY id ASC - array('catid DESC', 'id') => ORDER BY catid DESC, id
integer $start Limit start number.
integer $limit Limit rows.

Return Value

mixed Found rows data set.

at line line 53
mixed findAll(mixed $order = null, integer $start = null, integer $limit = null)

Find records without where conditions and return data set.

Same as $mapper->find(null, 'id', $start, $limit);

Parameters

mixed $order Order sort, can ba string, array or object. Example: - 'id ASC' => ORDER BY id ASC - array('catid DESC', 'id') => ORDER BY catid DESC, id
integer $start Limit start number.
integer $limit Limit rows.

Return Value

mixed Found rows data set.

at line line 72
mixed findOne(mixed $conditions = array(), mixed $order = null)

Find one record and return a data.

Same as $mapper->find($conditions, 'id', 0, 1);

Parameters

mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'
mixed $order Order sort, can ba string, array or object. Example: - id ASC => ORDER BY id ASC - array('catid DESC', 'id') => ORDER BY catid DESC, id

Return Value

mixed Found row data.

at line line 94
mixed findColumn(string $column, mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)

Find column as an array.

Parameters

string $column The column we want to select.
mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'
mixed $order Order sort, can ba string, array or object. Example: - id ASC => ORDER BY id ASC - array('catid DESC', 'id') => ORDER BY catid DESC, id
integer $start Limit start number.
integer $limit Limit rows.

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 103
mixed create(mixed $dataset)

Create records by data set.

Parameters

mixed $dataset The data set contains data we want to store.

Return Value

mixed Data set data with inserted id.

at line line 112
mixed createOne(mixed $data)

Create one record by data object.

Parameters

mixed $data Send a data in and store.

Return Value

mixed Data with inserted id.

at line line 123
mixed update(mixed $dataset, array $condFields = null)

Update records by data set. Every data depend on this table's primary key to update itself.

Parameters

mixed $dataset Data set contain data we want to update.
array $condFields The where condition tell us record exists or not, if not set, will use primary key instead.

Return Value

mixed Updated data set.

at line line 141
mixed updateBatch(mixed $data, mixed $conditions = array())

Using one data to update multiple rows, filter by where conditions.

Example: $mapper->updateAll(new Data(array('published' => 0)), array('date' => '2014-03-02')) Means we make every records which date is 2014-03-02 unpublished.

Parameters

mixed $data The data we want to update to every rows.
mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'

Return Value

mixed Updated data set.

at line line 152
mixed updateOne(mixed $data, array $condFields = null)

Same as update(), just update one row.

Parameters

mixed $data The data we want to update.
array $condFields The where condition tell us record exists or not, if not set, will use primary key instead.

Return Value

mixed Updated data.

at line line 166
mixed flush(mixed $dataset, mixed $conditions = array())

Flush records, will delete all by conditions then recreate new.

Parameters

mixed $dataset Data set contain data we want to update.
mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'

Return Value

mixed Updated data set.

at line line 178
mixed save(mixed $dataset, array $condFields = null)

Save will auto detect is conditions matched in data or not.

If matched, using update, otherwise we will create it as new record.

Parameters

mixed $dataset The data set contains data we want to save.
array $condFields The where condition tell us record exists or not, if not set, will use primary key instead.

Return Value

mixed Saved data set.

at line line 189
mixed saveOne(mixed $data, array $condFields = null)

Save only one row.

Parameters

mixed $data The data we want to save.
array $condFields The where condition tell us record exists or not, if not set, will use primary key instead.

Return Value

mixed Saved data.

at line line 202
boolean delete(mixed $conditions)

Delete records by where conditions.

Parameters

mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'

Return Value

boolean Will be always true.