Methods
Implements dynamic Model_Crud::find_by_{column} and Model_Crud::find_one_by_{column}
methods.
__callStatic(string $name, string $args) : mixed
Parameters
$name
string
The method name
$args
string
The method args
Exceptions
Returns
mixed
Based on static::$return_type
Sets up the object.
__construct(array $data)
Parameters
$data
array
The data array
Magic getter to fetch data from the data container
__get(string $property) : mixed
Parameters
$property
string
The property name
Returns
mixed
Magic isset to check if values exist
__isset(string $property) : bool
Parameters
$property
string
The property name
Returns
bool
whether or not the property exists
Magic setter so new objects can be assigned values
__set(string $property, mixed $value) : void
Parameters
$property
string
The property name
$value
mixed
The property value
Magic unset to remove existing properties
__unset(string $property)
Parameters
$property
string
The property name
Count all of the rows in the table.
count(string $column, bool $distinct, array $where, string $group_by) : int
Parameters
$column
string
Column to count by
$distinct
bool
Whether to count only distinct rows (by column)
$where
array
Query where clause(s)
$group_by
string
Column to group by
Exceptions
Returns
int
The number of rows OR false
Deletes this record and freezes the object
delete() : mixed
Returns
mixed
Rows affected
Finds all records.
find(array $config, string $key) : array | null
Parameters
$config
array
array containing query settings
$key
string
optional array index key
Returns
array
null
an array containing models or null if none are found
Finds all records in the table.
find_all(int $limit, int $offset) : null | object
Optionally limited and offset.
Parameters
$limit
int
Number of records to return
$offset
int
What record to start at
Returns
null
object
Null if not found or an array of Model object
Finds all records where the given column matches the given value using
the given operator ('=' by default).
find_by(string $column, mixed $value, string $operator, int $limit, int $offset) : null | object
Optionally limited and offset.
Parameters
$column
string
The column to search
$value
mixed
The value to find
$operator
string
The operator to search with
$limit
int
Number of records to return
$offset
int
What record to start at
Returns
null
object
Null if not found or an array of Model object
Finds a row with the given primary key value.
find_by_pk(mixed $value) : null | object
Parameters
$value
mixed
The primary key value to find
Returns
null
object
Either null or a new Model object
Finds a row with the given column value.
find_one_by(mixed $column, mixed $value, string $operator) : null | object
Parameters
$column
mixed
The column to search
$value
mixed
The value to find
$operator
string
Returns
null
object
Either null or a new Model object
Either checks if the record is frozen or sets whether it is frozen or not.
frozen(bool | null $frozen) : bool | \Fuel\Core\Model_Crud
fluent |
This method is part of a fluent interface and will return the same instance |
Parameters
$frozen
bool
null
Whether this is a frozen record
Returns
Either checks if the record is new or sets whether it is new or not.
is_new(bool | null $new) : bool | \Fuel\Core\Model_Crud
fluent |
This method is part of a fluent interface and will return the same instance |
Parameters
$new
bool
null
Whether this is a new record
Returns
Checks if the given offset (class property) exists.
offsetExists(string $offset) : bool
Parameters
$offset
string
class property
Returns
bool
Gets the value of the given offset (class property).
offsetGet(string $offset) : mixed
Parameters
$offset
string
class property
Returns
mixed
Sets the value of the given offset (class property).
offsetSet(string $offset, string $value) : void
Parameters
$offset
string
class property
Unsets the given offset (class property).
offsetUnset(string $offset) : void
Parameters
$offset
string
class property
Implementation of the Iterator interface
rewind()
Enable sanitization mode in the object
sanitize() : \Fuel\Core\Model_Crud
fluent |
This method is part of a fluent interface and will return the same instance |
Returns
Returns the current sanitization state of the object
sanitized() : bool
Saves the object to the database by either creating a new record
or updating an existing record.
save(bool $validate) : array | int
Sets the default values if set.
Parameters
$validate
bool
whether to validate the input
Exceptions
Returns
array
int
Rows affected and or insert ID
Serializable implementation: serialize
serialize() : array
Sets an array of values to class properties
set(array $data) : \Fuel\Core\Model_Crud
fluent |
This method is part of a fluent interface and will return the same instance |
Parameters
Returns
Returns all of $this object's public properties as an associative array.
to_array() : array
Disable sanitization mode in the object
unsanitize() : \Fuel\Core\Model_Crud
fluent |
This method is part of a fluent interface and will return the same instance |
Returns
Serializable implementation: unserialize
unserialize(string $data) : array
Parameters
$data
string
Returns
array
model data
Returns whether the instance will pass validation.
validates() : bool
Returns
bool
whether the instance passed validation
Returns the a validation object for the model.
validation() : object
Returns
object
Validation object
Get the connection to use for reading or writing
get_connection(boolean $writable) : mixed
Parameters
$writable
boolean
Get a writable connection
Returns
mixed
Database profile name (string) or Database_Connection (object)
Gets called after the delete query is executed and right before
it is returned.
post_delete(int $result) : int
Parameters
$result
int
Number of affected rows
Returns
int
Gets called after the query is executed and right before it is returned.
post_find(array | null $result) : array | null
$result will be null if 0 rows are returned.
Parameters
$result
array
null
the result array or null when there was no result
Returns
array
null
Gets called after the insert query is executed and right before
it is returned.
post_save(array $result) : array
Parameters
$result
array
insert id and number of affected rows
Returns
array
Gets called after the update query is executed and right before
it is returned.
post_update(int $result) : int
Parameters
$result
int
Number of affected rows
Returns
int
Called right after the validation is ran.
post_validate(bool $result) : bool
Parameters
$result
bool
Validation result
Returns
bool
Gets called before the delete query is executed.
pre_delete(\Fuel\Core\Database_Query $query) : void
Must return the query object.
Parameters
Gets called before the query is executed.
pre_find(\Fuel\Core\Database_Query $query) : void
Must return the query object.
Parameters
Gets called before the insert query is executed.
pre_save(\Fuel\Core\Database_Query $query) : void
Must return
the query object.
Parameters
Gets called before the update query is executed.
pre_update(\Fuel\Core\Database_Query $query) : void
Must return the query object.
Parameters
Gets called before the validation is ran.
pre_validate(array $data) : array
Parameters
$data
array
The validation data
Returns
array
Called right after values retrieval, before save,
update, setting defaults and validation.
prep_values(array $values) : array
Get the primary key for the current Model
primary_key() : string
Run validation
run_validation(array $vars) : bool
Parameters
$vars
array
array to validate
Returns
bool
validation result
Properties
<p>Data container for this object</p>
$_data : array
<p>If this is a record is frozen</p>
$_is_frozen : bool
<p>If this is a new record</p>
$_is_new : bool
<p>If this is a records data will be sanitized on get</p>
$_sanitization_enabled : bool
<p>The validation instance</p>
$_validation : object