Some design ideas borrowed from https://github.com/hubspace/fuel-nestedset
(see http://fuelphp.com/forums/discussion/12206/fuel-nested-sets)
Methods
Allow for getter, setter and unset methods
__call(string $method, array $args) : mixed
Inherited
inherited_from |
\Orm\Model::__call() |
Parameters
$method
string
$args
array
Exceptions
Returns
mixed
__callStatic()
__callStatic($method, $args)
Inherited
inherited_from |
\Orm\Model::__callStatic() |
Parameters
$method
$args
Allow object cloning to new object
__clone()
Inherited
inherited_from |
\Orm\Model::__clone() |
Constructor
__construct(array $data, $new, $view, $cache)
Fetch a property or relation
__get($property) : mixed
Inherited
inherited_from |
\Orm\Model::__get() |
Parameters
Returns
mixed
Check whether a property exists, only return true for table columns, relations, eav and custom data
__isset(string $property) : bool
Inherited
inherited_from |
\Orm\Model::__isset() |
Parameters
$property
string
Returns
bool
Set a property or relation
__set($property, $value) : \Orm\Model
Inherited
inherited_from |
\Orm\Model::__set() |
Parameters
Returns
Capture __unset() to make sure no read-only properties are erased
__unset(string $property)
Parameters
$property
string
Fetch or set relations on this object
To be used only after having fetched them from the database!
_relate(array | bool | null $rels) : void | array
Inherited
inherited_from |
\Orm\Model::_relate() |
Parameters
$rels
array
bool
null
Exceptions
\FuelException |
Invalid input for _relate(), should be an array |
\Orm\FrozenObject |
No changes allowed |
Returns
void
array
Update the original setting for this object
_update_original(array | null $original)
Inherited
inherited_from |
\Orm\Model::_update_original() |
Parameters
$original
array
null
Update the original relations for this object
_update_original_relations($relations)
Inherited
inherited_from |
\Orm\Model::_update_original_relations() |
Parameters
$relations
Returns a query object on the selected tree
build_query(bool $include_related) : \Orm\Query
Parameters
$include_related
bool
whether or not to include related models
Returns
Attempt to retrieve an earlier loaded object
cached_object(array | \Orm\Model $obj, null | string $class) : \Orm\Model | false
Inherited
inherited_from |
\Orm\Model::cached_object() |
Parameters
$class
null
string
Returns
Alias for last_child()
child(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Get a defined condition for this class
condition(string $type) : array
Inherited
inherited_from |
\Orm\Model::condition() |
Parameters
$type
string
type of condition to return
Returns
array
Fetch the database connection name to use
connection(bool $writeable) : null | string
Inherited
inherited_from |
\Orm\Model::connection() |
Parameters
$writeable
bool
if true return the writeable connection (if set)
Returns
null
string
Count entries, optionally only those matching the $options
count(array $options) : int
Inherited
inherited_from |
\Orm\Model::count() |
Parameters
Returns
int
Return the count of the objects children
count_children() : mixed
Returns
mixed
integer, or false in case no valid object was passed
Return the count of the objects descendants
count_descendants() : mixed
Returns
mixed
integer, or false in case no valid object was passed
current()
current()
Inherited
inherited_from |
\Orm\Model::current() |
Capture calls to delete(), to make sure no delete happens without reindexing
delete(mixed $cascade, $use_transaction) : \Orm\Model
Parameters
$cascade
mixed
null = use default config, bool = force/prevent cascade, array cascades only the relations that are in the array
$use_transaction
Exceptions
\Orm\DomainException |
if you try to delete a root node with multiple children |
Returns
\Orm\Model
this instance as a new object without primary key(s)
Deletes the entire tree structure using the current node as starting point
delete_tree(mixed $cascade, $use_transaction) : \Orm\Model
Parameters
$cascade
mixed
null = use default config, bool = force/prevent cascade, array cascades only the relations that are in the array
$use_transaction
Returns
\Orm\Model
this instance as a new object without primary key(s)
Return the depth of the object in the tree, where the root = 0
depth() : mixed
Returns
mixed
integer, of false in case no valid object was found
Disable an observer event
disable_event(string $event) : void
Inherited
inherited_from |
\Orm\Model::disable_event() |
Parameters
$event
string
event to disable
Return the tree, with the current node as root, as a nested array structure
dump_tree(bool $as_object, string $children, string $path, string $pathuri) : array
Parameters
$as_object
bool
whether or not to return an array of objects
$children
string
property name to store the node's children
$path
string
property name to store the node's display path
$pathuri
string
property name to store the node's uri path
Returns
array
Enable a defined observer
enable_event(string $event) : void
Inherited
inherited_from |
\Orm\Model::enable_event() |
Parameters
$event
string
class name of the observer (including namespace)
Find one or more entries
find(int | null $id, array $options) : \Orm\Model | \Orm\Model[]
Inherited
inherited_from |
\Orm\Model::find() |
Parameters
$id
int
null
$options
array
Exceptions
Returns
Gets or sets the first child of a node
first_child(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Flush the object cache
flush_cache(null | string | object $class)
Inherited
inherited_from |
\Orm\Model::flush_cache() |
Parameters
$class
null
string
object
Create a new model instance
forge($data, $new, $view, $cache)
Inherited
inherited_from |
\Orm\Model::forge() |
Parameters
$data
$new
$view
$cache
Freeze the object to disallow changing it or saving it
freeze()
Inherited
inherited_from |
\Orm\Model::freeze() |
Allow populating this object from an array, and any related objects
from_array(array $values) : \Orm\Model
Inherited
inherited_from |
\Orm\Model::from_array() |
Parameters
$values
array
assoc array with named values to store in the object
Returns
\Orm\Model
this instance as a new object without primary key(s)
Check whether the object was frozen
frozen() : boolean
Inherited
inherited_from |
\Orm\Model::frozen() |
Returns
boolean
Get one or more tree nodes, and provide fallback for
the original model getter
get($query, array $conditions) : mixed
Gets a property or
relation from the
object
Parameters
$conditions
Exceptions
\Orm\BadMethodCallException |
if called without a parameter and without a node to fetch |
Returns
mixed
Generates an array with keys new & old that contain ONLY the values that differ between the original and
the current unsaved model.
get_diff() : array
Inherited
Note: relations are given as single or array of imploded pks
inherited_from |
\Orm\Model::get_diff() |
Returns
array
Returns a list of properties and their information with _to_array_exclude
properties removed.
get_filtered_properties() : array
Inherited
inherited_from |
\Orm\Model::get_filtered_properties() |
Returns
array
get_one()
get_one(\Orm\Query $query)
Provide the identifying details in the form of an array
get_pk_assoc() : array
Inherited
inherited_from |
\Orm\Model::get_pk_assoc() |
Returns
array
Creates a new query with optional settings up front, or return a pre-build
query to further chain upon
get_query() : \Orm\Query
Returns a list of properties that will be excluded when to_array() is used.
get_to_array_exclude() : array
Inherited
inherited_from |
\Orm\Model::get_to_array_exclude() |
Returns
array
Select a specific tree if the table contains multiple trees
get_tree_id() : mixed
Exceptions
\Orm\OutOfRangeException |
if no tree id has been set |
Returns
mixed
current tree id value
Check if the object has children
has_children() : bool
Check if the object has a next sibling
has_next_sibling() : bool
Check if the object has a parent
has_parent() : bool
Note: this is an alias for is_child()
Returns
bool
Check if the object has a previous sibling
has_previous_sibling() : bool
Check if the object is the ancestor of node
is_ancestor_of(\Orm\Model_Nestedset $child) : bool
Compare current state with the retrieved state
is_changed(string | array $property) : bool
Inherited
inherited_from |
\Orm\Model::is_changed() |
Parameters
$property
string
array
Exceptions
Returns
bool
Check if the object is a child node (not a root node)
is_child() : bool
Check if the object is a child of node
is_child_of(\Orm\Model_Nestedset $parent) : bool
Check if the object is a direct descendant of node
is_descendant_of(\Orm\Model_Nestedset $parent) : bool
is_fetched()
is_fetched($relation)
Inherited
inherited_from |
\Orm\Model::is_fetched() |
Parameters
$relation
Check if the object is a tree leaf (node with no children)
is_leaf() : bool
is_new()
is_new()
Inherited
inherited_from |
\Orm\Model::is_new() |
Check if the object is the parent of node
is_parent_of(\Orm\Model_Nestedset $child) : bool
Check if the object is a tree root
is_root() : bool
Check if the object is the same model
is_same_model_as(\Orm\Model_Nestedset $object) : bool
Check if the object is the same model and the same tree
is_same_tree_as(\Orm\Model_Nestedset $object) : bool
key()
key()
Inherited
inherited_from |
\Orm\Model::key() |
Gets or sets the last child of a node
last_child(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Find the maximum
max($key) : bool | int
Inherited
inherited_from |
\Orm\Model::max() |
Parameters
Returns
bool
int
Maximum value or false
Find the minimum
min($key) : object | array
Inherited
inherited_from |
\Orm\Model::min() |
Parameters
Returns
object
array
next()
next()
Inherited
inherited_from |
\Orm\Model::next() |
Gets or sets the next sibling of a node
next_sibling(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Calls all observers for the current event
observe($event)
Inherited
inherited_from |
\Orm\Model::observe() |
Parameters
Get the class's observers and what they observe
observers(string $specific, mixed $default) : array
Inherited
inherited_from |
\Orm\Model::observers() |
Parameters
$specific
string
specific observer to retrieve info of, allows direct param access by using dot notation
$default
mixed
default return value when specific key wasn't found
Returns
array
offsetExists()
offsetExists($offset)
Inherited
inherited_from |
\Orm\Model::offsetExists() |
Parameters
$offset
offsetGet()
offsetGet($offset)
Inherited
inherited_from |
\Orm\Model::offsetGet() |
Parameters
$offset
offsetSet()
offsetSet($offset, $value)
Inherited
inherited_from |
\Orm\Model::offsetSet() |
Parameters
$offset
$value
offsetUnset()
offsetUnset($offset)
Inherited
inherited_from |
\Orm\Model::offsetUnset() |
Parameters
$offset
Returns the path to the current node
path($addroot) : \Orm\Model_Nestedset
Parameters
$addroot
Returns
Gets or sets the previous sibling of a node
previous_sibling(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Get the primary key(s) of this class
primary_key() : array
Inherited
inherited_from |
\Orm\Model::primary_key() |
Returns
array
Get the class's properties
properties() : array
Inherited
inherited_from |
\Orm\Model::properties() |
Exceptions
\FuelException |
Listing columns failed |
Returns
array
Fetches a property description array, or specific data from it
property(string $key, mixed $default) : mixed
Inherited
inherited_from |
\Orm\Model::property() |
Parameters
$key
string
property or property.key
$default
mixed
return value when key not present
Returns
mixed
Creates a new query with optional settings up front
query($options) : \Orm\Query
Inherited
inherited_from |
\Orm\Model::query() |
Parameters
Returns
Register an observer
register_observer(string $name, mixed $options) : void
Inherited
inherited_from |
\Orm\Model::register_observer() |
Parameters
$name
string
class name of the observer (including namespace)
$options
mixed
observer options
Reset values to those gotten from the database
reset()
Inherited
inherited_from |
\Orm\Model::reset() |
rewind()
rewind()
Inherited
inherited_from |
\Orm\Model::rewind() |
Enable sanitization mode in the object
sanitize() : \Orm\Model_Nestedset
Inherited
inherited_from |
\Orm\Model::sanitize() |
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
Inherited
inherited_from |
\Orm\Model::sanitized() |
Returns
bool
Capture calls to save(), to make sure no new record is inserted
directly which would seriously break the tree.
save(mixed $cascade, $use_transaction) : bool
..
Parameters
$cascade
mixed
null = use default config, bool = force/prevent cascade, array cascades only the relations that are in the array
$use_transaction
Returns
bool
Capture set() to make sure no read-only properties are overwritten
set(string | array $property, string $value) : \Orm\Model
Sets a property or
relation of the
object
Parameters
$property
string
array
$value
string
in case $property is a string
Exceptions
Returns
Sets the connection to use for this model.
set_connection(string $connection)
Inherited
inherited_from |
\Orm\Model::set_connection() |
Parameters
$connection
string
Select a specific tree if the table contains multiple trees
set_tree_id(mixed $tree) : \Orm\Model_Nestedset
Parameters
$tree
mixed
type depends on the field type of the tree_field
Exceptions
\Orm\BadMethodCallException |
if the model is not multi-tree |
Returns
Sets the write connection to use for this model.
set_write_connection(string $connection)
Inherited
inherited_from |
\Orm\Model::set_write_connection() |
Parameters
$connection
string
Alias for next_sibling()
sibling(\Orm\Model_Nestedset, $to) : \Orm\Model_Nestedset
Parameters
$to
\Orm\Model_Nestedset,
or PK of the parent object, or null
Returns
Returns the siblings of the current node (includes the node itself!)
siblings() : \Orm\Model_Nestedset
Get the table name for this class
table() : string
Inherited
inherited_from |
\Orm\Model::table() |
Returns
string
Allow converting this object to a real object
to_object($custom, $recurse) : object
Inherited
inherited_from |
\Orm\Model::to_object() |
Parameters
$custom
$recurse
Returns
object
Get a tree configuration parameter
tree_config(string $name) : mixed
Parameters
$name
string
name of the parameter to get
Returns
mixed
parameter value, or null if the parameter does not exist
Unfreeze the object to allow changing it or saving it again
unfreeze()
Inherited
inherited_from |
\Orm\Model::unfreeze() |
Unregister an observer
unregister_observer(string $name) : void
Inherited
inherited_from |
\Orm\Model::unregister_observer() |
Parameters
$name
string
class name of the observer (including namespace)
Disable sanitization mode in the object
unsanitize() : \Orm\Model_Nestedset
Inherited
inherited_from |
\Orm\Model::unsanitize() |
fluent |
This method is part of a fluent interface and will return the same instance |
Returns
valid()
valid()
Inherited
inherited_from |
\Orm\Model::valid() |
Fetch the model's views
views() : array
Inherited
inherited_from |
\Orm\Model::views() |
Exceptions
Returns
array
_fetch_nodes()
_fetch_nodes($action)
EAV attribute getter.
_get_eav($attribute, $isset, $unset) : mixed
Inherited
Also deals with isset() and unset()
inherited_from |
\Orm\Model::_get_eav() |
Parameters
$attribute
$isset
$unset
Exceptions
Returns
mixed
Interal tree operation.
_move_subtree(integer $destination_id)
Move the current node and all children
to a new position in the tree
Parameters
$destination_id
integer
new left pointer location to move to
Check if the object passed is an instance of the current model
_same_model_as($object, string $method) : bool
Parameters
$method
string
optional method name to display in the exception message
Exceptions
\Orm\OutOfBoundsException |
in case the two objects are not part of the same model |
Returns
bool
Sanitizatize a data value
_sanitize(string $field, mixed $value) : mixed
Inherited
inherited_from |
\Orm\Model::_sanitize() |
Parameters
$field
string
Name of the property that is being sanitized
$value
mixed
Value to sanitize
Returns
mixed
EAV attribute setter
_set_eav(string $attribute, string $value) : mixed
Inherited
inherited_from |
\Orm\Model::_set_eav() |
Parameters
$attribute
string
$value
string
Exceptions
Returns
mixed
Interal tree operation.
_shift_rl_range(integer $first, integer $last, integer $delta)
Shift left-right pointers to make room for
one or mode nodes, or to re-order the pointers after a delete
operation, in the given range
Parameters
$first
integer
left pointer of the first node to shift
$last
integer
right pointer of the last node to shift
$delta
integer
number of positions to shift (if negative the shift will be to the left)
Interal tree operation.
_shift_rl_values(integer $first, integer $delta)
Shift left-right pointers to make room for
one or mode nodes, or to re-order the pointers after a delete
operation.
Parameters
$first
integer
left pointer of the first node to shift
$delta
integer
number of positions to shift (if negative the shift will be to the left)
Adds the primary keys in where clauses to the given query.
add_primary_keys_to_where(\Orm\Query $query)
Inherited
inherited_from |
\Orm\Model::add_primary_keys_to_where() |
Parameters
Save using INSERT
create()
Inherited
inherited_from |
\Orm\Model::create() |
Deletes this model instance from the database.
delete_self() : bool
Inherited
inherited_from |
\Orm\Model::delete_self() |
Returns
bool
Allows subclasses to more easily define if a relation can be cascade deleted or not.
should_cascade_delete(array $rel) : bool
Inherited
inherited_from |
\Orm\Model::should_cascade_delete() |
Parameters
$rel
array
Returns
bool
False to stop the relation from being deleted. Works the same as the cascade_delete property
Save using UPDATE
update()
Inherited
inherited_from |
\Orm\Model::update() |
Properties
<p>array of fetched objects</p>
$_cached_objects : array
Inherited
inherited_from |
\Orm\Model::$$_cached_objects |
<p>Name of DB connection to use</p>
$_connection : string
Inherited
inherited_from |
\Orm\Model::$$_connection |
<p>id value of the current tree in multi-tree models</p>
$_current_tree_id : mixed
<p>storage for custom properties on this object</p>
$_custom_data : array
Inherited
inherited_from |
\Orm\Model::$$_custom_data |
<p>keeps the current state of the object</p>
$_data : array
Inherited
inherited_from |
\Orm\Model::$$_data |
$_data_relations
$_data_relations : array
Inherited
inherited_from |
\Orm\Model::$$_data_relations |
<p>disabled observer events</p>
$_disabled_events : array
Inherited
inherited_from |
\Orm\Model::$$_disabled_events |
<p>keeps to object frozen</p>
$_frozen : bool
Inherited
inherited_from |
\Orm\Model::$$_frozen |
<p>keeps track of whether it's a new object</p>
$_is_new : bool
Inherited
inherited_from |
\Orm\Model::$$_is_new |
$_iterable
$_iterable
Inherited
inherited_from |
\Orm\Model::$$_iterable |
<p>store the node operation we need to execute on save() or get()</p>
$_node_operation : array
<p>cached observers</p>
$_observers_cached : array
Inherited
inherited_from |
\Orm\Model::$$_observers_cached |
<p>keeps a copy of the object as it was retrieved from the database</p>
$_original : array
Inherited
inherited_from |
\Orm\Model::$$_original |
<p>keeps a copy of the relation ids that were originally retrieved from the database</p>
$_original_relations : array
Inherited
inherited_from |
\Orm\Model::$$_original_relations |
<p>name or names of the primary keys</p>
$_primary_key : array
Inherited
inherited_from |
\Orm\Model::$$_primary_key |
<p>cached properties</p>
$_properties_cached : array
Inherited
inherited_from |
\Orm\Model::$$_properties_cached |
<p>relationships</p>
$_relations_cached : string
Inherited
inherited_from |
\Orm\Model::$$_relations_cached |
<p>keeps track of relations that need to be reset before saving the new ones</p>
$_reset_relations : array
Inherited
inherited_from |
\Orm\Model::$$_reset_relations |
<p>If this is a records data will be sanitized on get</p>
$_sanitization_enabled : bool
Inherited
inherited_from |
\Orm\Model::$$_sanitization_enabled |
<p>cached tables</p>
$_table_names_cached : array
Inherited
inherited_from |
\Orm\Model::$$_table_names_cached |
<p>name or columns that need to be excluded from any to_array() result</p>
$_to_array_exclude : array
Inherited
inherited_from |
\Orm\Model::$$_to_array_exclude |
<p>cached tree configurations</p>
$_tree_cached : array
<p>array of valid relation types</p>
$_valid_relations : array
Inherited
inherited_from |
\Orm\Model::$$_valid_relations |
<p>view name when used</p>
$_view : string
Inherited
inherited_from |
\Orm\Model::$$_view |
<p>cached properties</p>
$_views_cached : array
Inherited
inherited_from |
\Orm\Model::$$_views_cached |
<p>Name of the DB connection to use when writing</p>
$_write_connection : string
Inherited
inherited_from |
\Orm\Model::$$_write_connection |
<p>global array to track circular references in to_array()</p>
$to_array_references : array
Inherited
inherited_from |
\Orm\Model::$$to_array_references |