A Mapper that uses MySQL. Cool enne?
This class has no SQL Injection protection so please sanitize the data before
you send data to the database.
Methods
Creates a new mapper. You can optionally pass in the data source adapter.
__construct(Adapter $adapter)
Inherited
inherited_from |
\Cactus\Mapper::__construct() |
Parameters
Get all of the records in the data set.
all(string $column, string $direction) : \Cactus\Collection
Parameters
$column
string
The column to sort on
$direction
string
The direction to sort on (ASC or DESC)
Returns
Deletes an entity.
delete(Entity $entity) : boolean
Parameters
Returns
boolean
Was the delete successful?
Filters the data to make sure only fields that are specified in the mapper
get set in the query.
filter(mixed $data, array $columns) : array
Inherited
inherited_from |
\Cactus\Mapper::filter() |
Parameters
$data
mixed
The data to filter.
$columns
array
The columns to filter on.
Returns
array
The filtered data
Gets all of the records that satisfy the search parameters.
find(array $params) : \Cactus\Collection
Parameters
$params
array
The search parameters
Returns
Attempt to get a row of data by using the passed in key.
get(mixed $key) : \Cactus\Entity
Parameters
$key
mixed
The value of the primary key that is used to find the data
Returns
Gets the column list of the mapper.
getColumns() : array
Inherited
inherited_from |
\Cactus\Mapper::getColumns() |
Returns
array
Gets the validation rules.
getValidationRules() : array
Inherited
inherited_from |
\Cactus\Mapper::getValidationRules() |
Returns
array
Saves an entity.
save(Entity $entity) : mixed
Parameters
Returns
mixed
create = array($id, $affected) | update = $affected
Creates a new row.
create(Entity $entity) : array
Parameters
Returns
array
array($id, $affected)
An initilization function so we don't have to override the constructor.
init()
Inherited
inherited_from |
\Cactus\Mapper::init() |
Prepares the data to return to the data store (as strings).
prepareData(Entity $entity) : array
Inherited
inherited_from |
\Cactus\Mapper::prepareData() |
Parameters
Returns
array
The modified/filtered/reverted data...
Updates an existing entity.
update(Entity $entity) : int
Parameters
Returns
int
Affected rows
Properties
The adapter used to fetch data
$adapter : \Cactus\Adapter
Inherited
inherited_from |
\Cactus\Mapper::$$adapter |
The object class to return rows as
$objectClass : string
Inherited
inherited_from |
\Cactus\Mapper::$$objectClass |
A listing of columns in the data
$columns : array
Inherited
inherited_from |
\Cactus\Mapper::$$columns |
The name of the primary key column
$primary_key : string
Inherited
inherited_from |
\Cactus\Mapper::$$primary_key |
A list of validation rules.
$rules : array
Inherited
inherited_from |
\Cactus\Mapper::$$rules |
The database table
$table : string
Inherited
inherited_from |
\Cactus\Mapper::$$table |