interface DatabaseMapperInterface implements DataMapperInterface (View source)

The DatabaseMapperInterface class.

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.

array
getFields(string $table = null)

Get table fields.

string
getTable()

Get table name.

getDb()

Get DB adapter.

setDb(AbstractDatabaseDriver $db)

Set db adapter.

Details

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.

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.

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.

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

at line line 27
array getFields(string $table = null)

Get table fields.

Parameters

string $table Table name.

Return Value

array

at line line 34
string getTable()

Get table name.

Return Value

string Table name.

at line line 41
AbstractDatabaseDriver getDb()

Get DB adapter.

Return Value

AbstractDatabaseDriver Db adapter.

at line line 50
DataMapper setDb(AbstractDatabaseDriver $db)

Set db adapter.

Parameters

AbstractDatabaseDriver $db Db adapter.

Return Value

DataMapper Return self to support chaining.