AbstractDataMapper
class AbstractDataMapper implements DataMapperInterface (View source)
Abstract DataMapper.
The class can implement by any database system.
Constants
UPDATE_NULLS |
|
Methods
Init this class.
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.
Create records by data set.
Create one record by data object.
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.
Delete records by where conditions.
Get table fields.
Get table name.
Set table name.
Get data class.
Set data class.
Get data set class.
Set Data set class.
To use transaction or not.
Method to get property Dispatcher
Method to get the primary key field name for the table.
Validate that the primary key has been set.
Details
at line line 105
__construct(string $table = null, string $keys = null)
Init this class.
We don't dependency on database in abstract class, that means you can use other data provider.
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);
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);
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 307
mixed
findColumn(string $column, mixed $conditions = array(), mixed $order = null, integer $start = null, integer $limit = null)
Find column as an array.
at line line 349
mixed
create(mixed $dataset)
Create records by data set.
at line line 379
mixed
createOne(mixed $data)
Create one record by data object.
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.
at line line 445
mixed
updateOne(mixed $data, array $condFields = null, bool $updateNulls = false)
Same as update(), just update one row.
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.
at line line 512
mixed
flush(mixed $dataset, mixed $conditions = array())
Flush records, will delete all by conditions then recreate new.
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.
at line line 626
mixed
saveOne(mixed $data, array $condFields = null, bool $updateNulls = false)
Save only one row.
at line line 658
boolean
delete(mixed $conditions)
Delete records by where conditions.
at line line 773
abstract array
getFields(string $table = null)
Get table fields.
at line line 780
string
getTable()
Get table name.
at line line 792
AbstractDataMapper
setTable(string $table)
Set table name.
at line line 870
string
getDataClass()
Get data class.
at line line 882
AbstractDataMapper
setDataClass(string $dataClass)
Set data class.
at line line 894
string
getDatasetClass()
Get data set class.
at line line 906
AbstractDataMapper
setDatasetClass(string $datasetClass)
Set Data set class.
at line line 920
boolean
useTransaction(boolean $yn = null)
To use transaction or not.
at line line 966
DispatcherInterface
getDispatcher()
Method to get property Dispatcher
at line line 988
AbstractDataMapper
setDispatcher(DispatcherInterface $dispatcher)
Method to set property dispatcher
at line line 1004
array|mixed
getKeyName(boolean $multiple = false)
Method to get the primary key field name for the table.
at line line 1031
boolean
hasPrimaryKey()
Validate that the primary key has been set.