Class Model

Description

Model Class

This is a parent class that all PICKLES data models should be extending. When using the class as designed, objects will function as active record pattern objects.

Located in /classes/Model.php (line 25)

Object
   |
   --Model
Variable Summary
object $cache
mixed $collection
mixed $conditions
string $datasource
object $db
boolean $delayed
mixed $fields
mixed $group
mixed $having
mixed $hints
string $id
boolean $ignore
mixed $joins
mixed $limit
mixed $offset
mixed $order
string $priority
array $record
array $records
boolean $replace
array $results
mixed $table
boolean $use_cache
Method Summary
Model __construct ([mixed $type_or_parameters = null], [array $parameters = null])
boolean commit ()
void count ()
boolean delete ()
boolean end ()
void execute ([mixed $type_or_parameters = null], [array $parameters = null])
boolean first ()
boolean last ()
boolean next ()
boolean prev ()
boolean reset ()
boolean shuffle ()
boolean sort (string $index, [string $order = 'ASC'])
string unescape (string $value)
mixed walk ()
Variables
object $cache = null (line 43)

Cache Object

  • access: protected
mixed $collection = false (line 145)

Collection Name

For compatibility with the naming conventions used by MongoDB, the collection name can be specified. If the collection name is set, it will set the table name value to it and proceed as normal.

  • access: protected
mixed $conditions = false (line 169)

Conditions

  • access: protected
string $datasource (line 75)

Datasource

  • access: protected
object $db = null (line 35)

Database Object

  • access: protected
boolean $delayed = false (line 93)

Delayed Insert

  • access: protected
mixed $fields = '*' (line 117)

Field List

  • access: protected
mixed $group = false (line 177)

Group

  • access: protected
mixed $having = false (line 185)

Having

  • access: protected
mixed $hints = false (line 161)

[Index] Hints

  • access: protected
string $id = 'id' (line 133)

ID Column

  • access: protected
boolean $ignore = false (line 101)

Ignore Unique Index

  • access: protected
mixed $joins = false (line 153)

Joins

  • access: protected
mixed $limit = false (line 201)

Limit

  • access: protected
mixed $offset = false (line 209)

Offset

  • var: (string or array)
  • access: protected
mixed $order = false (line 193)

Order

  • access: protected
string $priority = false (line 85)

Insert Priority

Defaults to false (normal priority) but can be set to "low" or "high"

  • access: protected
array $record = null (line 232)

Record

  • access: public
array $records = null (line 239)

Records

  • access: public
boolean $replace = false (line 109)

Replace instead of Insert/Update?

  • access: protected
array $results = null (line 217)

Query Results

  • access: protected
mixed $table = false (line 125)

Table Name

  • access: protected
boolean $use_cache = false (line 51)

Whether or not to use cache

  • access: protected
Methods
Constructor __construct (line 300)

Constructor

Creates a new (empty) object or populates the record set.

  • access: public
Model __construct ([mixed $type_or_parameters = null], [array $parameters = null])
  • mixed $type_or_parameters: optional type of query or parameters
  • array $parameters: optional data to create a query from
commit (line 982)

Commit

Inserts or updates a record in the database.

  • return: results of the query
  • access: public
boolean commit ()
count (line 810)

Count Records

Counts the records

  • access: public
void count ()
delete (line 1121)

Delete Record

Deletes the current record from the database

  • return: status of the query
  • access: public
boolean delete ()
end (line 920)

End Record

Set the pointer to the last element of the record set.

  • return: whether or not records is an array (and end() worked)
  • access: public
boolean end ()
execute (line 340)

Execute

Potentially populates the record set from the passed arguments.

  • access: public
void execute ([mixed $type_or_parameters = null], [array $parameters = null])
  • mixed $type_or_parameters: optional type of query or parameters
  • array $parameters: optional data to create a query from
first (line 908)

First Record

Alias of reset(). "first" is more intuitive to me, but reset stays in line with the built in PHP functions.

  • return: whether or not records is an array (and could be reset)
  • access: public
boolean first ()
last (line 940)

Last Record

Alias of end(). "last" is more intuitive to me, but end stays in line with the built in PHP functions.

  • return: whether or not records is an array (and end() worked)
  • access: public
boolean last ()
next (line 850)

Next Record

Increment the record array to the next member of the record set.

  • return: whether or not there was next element
  • access: public
boolean next ()
prev (line 869)

Previous Record

Decrement the record array to the next member of the record set.

  • return: whether or not there was previous element
  • access: public
boolean prev ()
reset (line 888)

Reset Record

Set the pointer to the first element of the record set.

  • return: whether or not records is an array (and could be reset)
  • access: public
boolean reset ()
shuffle (line 838)

Shuffle Records

Sorts the records in a pseudo-random order.

  • return: true
  • todo: Implement this method
  • access: public
boolean shuffle ()
sort (line 825)

Sort Records

Sorts the records by the specified index in the specified order.

  • return: true
  • todo: Implement this method
  • access: public
boolean sort (string $index, [string $order = 'ASC'])
  • string $index: the index to be sorted on
  • string $order: the direction to order
unescape (line 1182)

Unescape String

Assuming magic quotes is turned on, strips slashes from the string

  • return: unescaped string
  • access: protected
string unescape (string $value)
  • string $value: string to be unescaped
walk (line 954)

Walk Records

Returns the current record and advances to the next. Built to allow for simplified code when looping through a record set.

  • return: either an array of the current record or false
  • todo: Does not currently support "indexed" or "list" return types
  • access: public
mixed walk ()

Documentation generated on Wed, 03 Oct 2012 17:46:05 -0400 by phpDocumentor 1.4.4