NestedRecord
class NestedRecord extends Record (View source)
The NestedRecord class.
Constants
DUMP_ALL_DATA |
|
UPDATE_NULLS |
|
LOAD_DEFAULT |
|
LOCATION_BEFORE |
|
LOCATION_AFTER |
|
LOCATION_FIRST_CHILD |
|
LOCATION_LAST_CHILD |
|
Methods
Object constructor to set table and key fields. In most cases this will be overridden by child classes to explicitly set the table and key fields for a particular database table.
Method to bind an associative array or object to the AbstractTable instance. This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.
Apply a user supplied function to every member of this object.
Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties (except $_errors).
Method to provide a shortcut to binding, checking and storing a AbstractTable instance to the database table. The method will check a row in once the data has been stored and if an ordering filter is present will attempt to reorder the table rows based on the filter. The ordering filter is an instance property name. The rows that will be reordered are those whose value matches the AbstractTable instance for the property specified.
Method to load a row from the database by primary key and bind the fields to the AbstractTable instance properties.
Method to delete a node and, optionally, its child nodes from the table.
Method to get the primary key field name for the table.
Check a field value exists in database or not, to keep a field unique.
Method to get an array of nodes from a given node to its root.
Method to get a node and all its child nodes.
Method to determine if a node is a leaf node in the tree (has no children).
Method to set the location of a node in the tree object. This method does not save the new location to the database, but will set it in the object so that when the node is stored it will be stored in the new location.
Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
Method to move a node and its children to a new location in the tree.
Gets the ID of the root item in the tree
Method to recursively rebuild the whole nested set tree.
Method to rebuild the node's path field from the alias values of the nodes from the current node to the root node of the tree.
createRoot
Details
__construct(string $table = null, mixed $keys = 'id', AbstractDataMapper $mapper = null)
Object constructor to set table and key fields. In most cases this will be overridden by child classes to explicitly set the table and key fields for a particular database table.
Data
bind(mixed $src, boolean $replaceNulls = false)
Method to bind an associative array or object to the AbstractTable instance. This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.
Data
set(string $key, mixed $value = null)
Magic setter to set a table field.
mixed
get(string $key, mixed $default = null)
Magic getter to get a table field.
Traversable
getIterator(bool $all = false)
Get an iterator object.
Data
walk(callable $callback, mixed $userdata = null)
Apply a user supplied function to every member of this object.
at line line 871
Entity
reset(bool $loadDefault = true)
Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties (except $_errors).
$this
save(mixed $src, boolean $updateNulls = false)
Method to provide a shortcut to binding, checking and storing a AbstractTable instance to the database table. The method will check a row in once the data has been stored and if an ordering filter is present will attempt to reorder the table rows based on the filter. The ordering filter is an instance property name. The rows that will be reordered are those whose value matches the AbstractTable instance for the property specified.
Record
load(mixed $keys = null, boolean $reset = true)
Method to load a row from the database by primary key and bind the fields to the AbstractTable instance properties.
at line line 554
Record
delete(integer $pk = null, boolean $children = true)
Method to delete a node and, optionally, its child nodes from the table.
at line line 175
Record
validate()
Checks that the object is valid and able to be stored.
This method checks that the parentid is non-zero and exists in the database. Note that the root node (parentid = 0) cannot be manipulated with this class.
at line line 240
Record
store(boolean $updateNulls = false)
Method to store a node in the database table.
array|mixed
getKeyName(boolean $multiple = false)
Method to get the primary key field name for the table.
bool
valueExists(string $field, null $value = null)
Check a field value exists in database or not, to keep a field unique.
DispatcherInterface
getDispatcher()
Method to get property Dispatcher
Record
setDispatcher(DispatcherInterface $dispatcher)
Method to set property dispatcher
AbstractDataMapper
getDataMapper()
Method to get property Mapper
Record
setDataMapper(AbstractDataMapper $mapper)
Method to set property mapper
at line line 83
mixed
getPath(integer $pk = null, boolean $allFields = false)
Method to get an array of nodes from a given node to its root.
at line line 114
mixed
getTree(integer $pk = null, boolean $allFields = false)
Method to get a node and all its child nodes.
at line line 145
boolean
isLeaf(integer $pk = null)
Method to determine if a node is a leaf node in the tree (has no children).
at line line 209
NestedRecord
setLocation(integer $referenceId, integer $position = self::LOCATION_AFTER)
Method to set the location of a node in the tree object. This method does not save the new location to the database, but will set it in the object so that when the node is stored it will be stored in the new location.
at line line 348
mixed
move(integer $delta, string $where = '')
Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
Negative numbers move the row up in the sequence and positive numbers move it down.
at line line 401
boolean
moveByReference(integer $referenceId, integer $position = self::LOCATION_AFTER, integer $pk = null)
Method to move a node and its children to a new location in the tree.
at line line 654
mixed
getRootId()
Gets the ID of the root item in the tree
at line line 706
integer
rebuild(integer $parentId = null, integer $leftId, integer $level, string $path = '')
Method to recursively rebuild the whole nested set tree.
at line line 785
boolean
rebuildPath(integer $pk = null)
Method to rebuild the node's path field from the alias values of the nodes from the current node to the root node of the tree.
at line line 838
boolean
createRoot()
createRoot