The mapper class is the gateway for defining data structures as well as knowing how to get them.

package Cactus
author Dave Widmer

 Methods

Creates a new mapper. You can optionally pass in the data source adapter.

__construct(Adapter $adapter) 

Parameters

$adapter

\Cactus\Adapter

The data adapter.

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

$entity

\Cactus\Entity

The entity to delete

Returns

booleanWas 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

Parameters

$data

mixed

The data to filter.

$columns

array

The columns to filter on.

Returns

arrayThe 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

Returns

array

Gets the validation rules.

getValidationRules() : array

Returns

array

Saves an entity.

save(Entity $entity) 

Parameters

$entity

\Cactus\Entity

The entity to save

Takes the result array and converts it and makes a collection out of it.

formCollection(array $result) : \Cactus\Collection

Parameters

$result

array

An array of results

Returns

An initilization function so we don't have to override the constructor.

init() 

Prepares the data to return to the data store (as strings).

prepareData(Entity $entity) : array

Parameters

$entity

\Cactus\Entity

The entity to prepare

Returns

arrayThe modified/filtered/reverted data...

 Properties

 

The adapter used to fetch data

$adapter : \Cactus\Adapter

 

The object class to return rows as

$objectClass : string

 

A listing of columns in the data

$columns : array

 

The name of the primary key column

$primary_key : string

 

A list of validation rules.

$rules : array

 

The database table

$table : string