DataMapper
class DataMapper extends AbstractDataMapper implements DatabaseMapperInterface (View source)
Main Database Mapper class.
Constants
UPDATE_NULLS |
|
Methods
Constructor.
Find records and return data set.
Find records without where conditions and return data set.
Find one record and return a data.
Find column as an array.
Update records by data set. Every data depend on this table's primary key to update itself.
Same as update(), just update one row.
Using one data to update multiple rows, filter by where conditions.
Flush records, will delete all by conditions then recreate new.
Save will auto detect is conditions matched in data or not.
Save only one row.
Get table fields.
Set Data set class.
Method to get the primary key field name for the table.
newRelation
Method to set property alias
Get DB adapter.
Method to get property Query
Method to get property QueryHelper
reset
join
__call
Details
at line line 99
__construct(string $table = null, string $keys = null, AbstractDatabaseDriver $db = null)
Constructor.
in AbstractDataMapper at line line 150
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);
in AbstractDataMapper at line line 226
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);
in AbstractDataMapper at line line 262
mixed
findOne(mixed $conditions = array(), mixed $order = null)
Find one record and return a data.
Same as $mapper->find($conditions, 'id', 0, 1);
at line line 482
mixed
findColumn(string $column, mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)
Find column as an array.
in AbstractDataMapper at line line 349
mixed
create(mixed $dataset)
Create records by data set.
in AbstractDataMapper at line line 379
mixed
createOne(mixed $data)
Create one record by data object.
in AbstractDataMapper at line line 408
mixed
update(mixed $dataset, array $condFields = null, bool $updateNulls = false)
Update records by data set. Every data depend on this table's primary key to update itself.
in AbstractDataMapper at line line 445
mixed
updateOne(mixed $data, array $condFields = null, bool $updateNulls = false)
Same as update(), just update one row.
in AbstractDataMapper at line line 482
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.
in AbstractDataMapper at line line 512
mixed
flush(mixed $dataset, mixed $conditions = array())
Flush records, will delete all by conditions then recreate new.
in AbstractDataMapper at line line 554
mixed
save(mixed $dataset, array $condFields = null, bool $updateNulls = false)
Save will auto detect is conditions matched in data or not.
If matched, using update, otherwise we will create it as new record.
in AbstractDataMapper at line line 626
mixed
saveOne(mixed $data, array $condFields = null, bool $updateNulls = false)
Save only one row.
in AbstractDataMapper at line line 658
boolean
delete(mixed $conditions)
Delete records by where conditions.
at line line 520
array
getFields(string $table = null)
Get table fields.
in AbstractDataMapper at line line 780
string
getTable()
Get table name.
in AbstractDataMapper at line line 792
AbstractDataMapper
setTable(string $table)
Set table name.
in AbstractDataMapper at line line 870
string
getDataClass()
Get data class.
in AbstractDataMapper at line line 882
AbstractDataMapper
setDataClass(string $dataClass)
Set data class.
in AbstractDataMapper at line line 894
string
getDatasetClass()
Get data set class.
in AbstractDataMapper at line line 906
AbstractDataMapper
setDatasetClass(string $datasetClass)
Set Data set class.
in AbstractDataMapper at line line 920
boolean
useTransaction(boolean $yn = null)
To use transaction or not.
in AbstractDataMapper at line line 938
Event
triggerEvent(string|Event $event, array $args = array())
triggerEvent
in AbstractDataMapper at line line 966
DispatcherInterface
getDispatcher()
Method to get property Dispatcher
in AbstractDataMapper at line line 988
AbstractDataMapper
setDispatcher(DispatcherInterface $dispatcher)
Method to set property dispatcher
in AbstractDataMapper at line line 1004
array|mixed
getKeyName(boolean $multiple = false)
Method to get the primary key field name for the table.
in AbstractDataMapper at line line 1031
boolean
hasPrimaryKey()
Validate that the primary key has been set.
at line line 85
static DataMapper
newRelation(string $alias = null, string $table = null, string $keys = null, AbstractDatabaseDriver $db = null)
newRelation
at line line 113
DataMapper
alias(string $alias)
Method to set property alias
at line line 494
AbstractDatabaseDriver
getDb()
Get DB adapter.
at line line 506
DataMapper
setDb(AbstractDatabaseDriver $db)
Set db adapter.
at line line 581
QueryInterface
getQuery(bool $new = false)
Method to get property Query
at line line 598
DataMapper
setQuery(QueryInterface $query)
Method to set property query
at line line 610
QueryHelper
getQueryHelper()
Method to get property QueryHelper
at line line 632
DataMapper
setQueryHelper(QueryHelper $queryHelper)
Method to set property queryHelper
at line line 644
DataMapper
reset()
reset
at line line 663
DataMapper
join(string $joinType = 'LEFT', string $alias, string $table, mixed $condition = null, boolean $prefix = null)
join
at line line 678
mixed
__call(string $name, array $args)
__call