eZPersistentObject Class Reference
[Kernel system]
Allows for object persistence in a database.
More...
Inheritance diagram for eZPersistentObject:
List of all members.
|
Public Methods |
| | eZPersistentObject ($row) |
| | fill (&$row) |
| & | fetchObject (&$def,$field_filters,$conds,$asObject=true,$grouping=null,$custom_fields=null) |
| | remove ($conditions=null,$extraConditions=null) |
| | removeObject (&$def,$conditions=null,$extraConditions=null) |
| | store ($fieldFilters=null) |
| | sync ($fieldFilters=null) |
| & | conditionText (&$conditions) |
| & | conditionTextByRow (&$conditions,&$row) |
| & | fetchObjectList (&$def,$field_filters=null,$conds=null,$sorts=null,$limit=null,$asObject=true,$grouping=false,$custom_fields=null) |
| | swapRow ($table,&$keys,&$order_id,&$rows,$id1,$id2) |
| | newObjectOrder (&$def,$orderField,$conditions) |
| | reorderObject (&$def,$orderField,$conditions,$down=true) |
| & | definition () |
| & | attributes () |
| | hasAttribute ($attr) |
| & | attribute ($attr) |
| | setAttribute ($attr,$val) |
| | hasDirtyData () |
| | setHasDirtyData ($hasDirtyData) |
Private Methods |
| | storeObject (&$obj,$fieldFilters=null) |
Private Attributes |
| | PersistentDataDirty |
Detailed Description
Allows for object persistence in a database.
Classes which stores simple types in databases should inherit from this and implement the definition() function. The class will then get initialization, fetching, listing, moving, storing and deleting for free as well as attribute access. The new class must have a constructor which takes one parameter called $row and pass that this constructor.
Definition at line ezpersistentobject.php.
Constructor & Destructor Documentation
| eZPersistentObject::eZPersistentObject |
( |
$ |
row |
) |
|
|
Member Function Documentation
| & eZPersistentObject::attribute |
( |
$ |
attr |
) |
|
|
| & eZPersistentObject::attributes |
( |
|
) |
|
|
| & eZPersistentObject::conditionText |
( |
&$ |
conditions |
) |
|
|
| & eZPersistentObject::conditionTextByRow |
( |
&$ |
conditions, |
|
|
&$ |
row |
|
) |
|
|
| & eZPersistentObject::definition |
( |
|
) |
|
|
|
|
- Returns:
-
the definition for the object, the default implementation is to return an empty array. It's upto each inheriting class to return a proper definition array.
The definition array is an associative array consists of these keys:
- fields - an associative array of fields which defines which database field (the key) is to fetched and how they map to object member variables (the value).
- keys - an array of fields which is used for uniquely identifying the object in the table.
- function_attributes - an associative array of attributes which maps to member functions, used for fetching data with functions.
- set_functions - an associative array of attributes which maps to member functions, used for setting data with functions.
- increment_key - the field which is incremented on table inserts.
- class_name - the classname which is used for instantiating new objecs when fetching from the database.
- sort - an associative array which defines the default sorting of lists, the key is the table field while the value is the sorting method which is either
asc or desc. - name - the name of the database table
Example: function definition()
{
return array( "fields" => array( "id" => "ID",
"version" => "Version",
"name" => "Name" ),
"keys" => array( "id", "version" ),
"function_attributes" => array( "current" => "currentVersion",
"class_name" => "className" ),
"increment_key" => "id",
"class_name" => "eZContentClass",
"sort" => array( "id" => "asc" ),
"name" => "ezcontentclass" );
}
Reimplemented in eZWaitUntilDateValue.
Definition at line ezpersistentobject.php.
Referenced by remove(). |
| & eZPersistentObject::fetchObject |
( |
&$ |
def, |
|
|
$ |
field_filters, |
|
|
$ |
conds, |
|
|
$ |
asObject = true, |
|
|
$ |
grouping = null, |
|
|
$ |
custom_fields = null |
|
) |
|
|
|
|
Creates an SQL query out of the different parameters and returns an object with the result. If $asObject is true the returned item is an object otherwise a db row. Uses fetchObjectList for the actual SQL handling and just returns the first row item. - Parameters:
-
| def |
The definition structure |
| field_filters |
If defined determines the fields which are extracted, if not all fields are fetched |
| conds |
An array of conditions which determines which rows are fetched |
| grouping |
An array of elements to group by |
| custom_fields |
An array of extra fields to fetch, each field may be a SQL operation |
Definition at line ezpersistentobject.php.
References fetchObjectList().
Referenced by eZSection::fetch(). |
| & eZPersistentObject::fetchObjectList |
( |
&$ |
def, |
|
|
$ |
field_filters = null, |
|
|
$ |
conds = null, |
|
|
$ |
sorts = null, |
|
|
$ |
limit = null, |
|
|
$ |
asObject = true, |
|
|
$ |
grouping = false, |
|
|
$ |
custom_fields = null |
|
) |
|
|
|
|
Creates an SQL query out of the different parameters and returns an array with the result. If $asObject is true the array contains objects otherwise a db row. - Parameters:
-
| def |
The definition structure |
| field_filters |
If defined determines the fields which are extracted, if not all fields are fetched |
| conds |
An array of conditions which determines which rows are fetched |
| sorts |
An array of sorting conditions |
| limit |
Offset and limit |
| grouping |
An array of elements to group by |
| custom_fields |
An array of extra fields to fetch, each field may be a SQL operation |
Definition at line ezpersistentobject.php.
References eZDB::instance().
Referenced by eZContentObject::versions(). |
| eZPersistentObject::fill |
( |
&$ |
row |
) |
|
|
|
|
Tries to fill in the data in the object by using the object definition which is returned by the function definition() and the database row data $row. Each field will be fetch from the definition and then use that fieldname to fetch from the row and set the data.
Definition at line ezpersistentobject.php.
References definition().
Referenced by eZPersistentObject(). |
| eZPersistentObject::hasAttribute |
( |
$ |
attr |
) |
|
|
| eZPersistentObject::hasDirtyData |
( |
|
) |
|
|
|
|
- Returns:
-
true if the data is considered dirty and needs to be stored.
- See also:
-
sync
Definition at line ezpersistentobject.php.
Referenced by sync(). |
| eZPersistentObject::newObjectOrder |
( |
&$ |
def, |
|
|
$ |
orderField, |
|
|
$ |
conditions |
|
) |
|
|
|
|
Returns an order value which can be used for new items in table, for instance placement. Uses $def, $orderField and $conditions to figure out the currently maximum order value and returns one that is larger.
Definition at line ezpersistentobject.php.
References eZDB::instance(). |
| eZPersistentObject::remove |
( |
$ |
conditions = null, |
|
|
$ |
extraConditions = null |
|
) |
|
|
|
|
Removes the object from the database, it will use the keys in the object definition to figure out which table row should be removed unless $conditions is defined as an array with fieldnames. It uses removeObject to do the real job and passes the object defintion, conditions and extra conditions $extraConditions to this function.
Reimplemented in eZWaitUntilDateValue.
Definition at line ezpersistentobject.php.
References removeObject().
Referenced by eZContentObject::remove(). |
| eZPersistentObject::removeObject |
( |
&$ |
def, |
|
|
$ |
conditions = null, |
|
|
$ |
extraConditions = null |
|
) |
|
|
|
|
Deletes the object from the table defined in $def with conditions $conditions and extra conditions $extraConditions. The extra conditions will either be appended to the existing conditions or overwrite existing fields. Uses conditionText() to create the condition SQL.
Definition at line ezpersistentobject.php.
References eZDB::instance().
Referenced by eZBinaryFile::remove(). |
| eZPersistentObject::reorderObject |
( |
&$ |
def, |
|
|
$ |
orderField, |
|
|
$ |
conditions, |
|
|
$ |
down = true |
|
) |
|
|
|
|
Moves a row in a database table. $def is the object definition. Uses $orderField to determine the order of objects in a table, usually this is a placement of some kind. It uses this order field to figure out how move the row, the row is either swapped with another row which is either above or below according to whether $down is true or false, or it is swapped with the first item or the last item depending on whether this row is first or last. Uses $conditions to figure out unique rows. - See also:
-
swapRow
- Parameters:
-
| orderField |
Associative array with one element, the key is the order id and values is order value. |
Definition at line ezpersistentobject.php.
References swapRow().
Referenced by eZContentClassAttribute::move(). |
| eZPersistentObject::setAttribute |
( |
$ |
attr, |
|
|
$ |
val |
|
) |
|
|
| eZPersistentObject::setHasDirtyData |
( |
$ |
hasDirtyData |
) |
|
|
| eZPersistentObject::store |
( |
$ |
fieldFilters = null |
) |
|
|
| eZPersistentObject::storeObject |
( |
&$ |
obj, |
|
|
$ |
fieldFilters = null |
|
) |
[private] |
|
| eZPersistentObject::swapRow |
( |
$ |
table, |
|
|
&$ |
keys, |
|
|
&$ |
order_id, |
|
|
&$ |
rows, |
|
|
$ |
id1, |
|
|
$ |
id2 |
|
) |
|
|
| eZPersistentObject::sync |
( |
$ |
fieldFilters = null |
) |
|
|
Member Data Documentation
eZPersistentObject::PersistentDataDirty [private]
|
|
The documentation for this class was generated from the following file:
|