eZPersistentObject Class Reference
[Kernel system]

Allows for object persistence in a database. More...

Inheritance diagram for eZPersistentObject:
eZBasket eZBinaryFile eZCollaborationGroup eZCollaborationItem eZCollaborationItemGroupLink eZCollaborationItemMessageLink eZCollaborationItemParticipantLink eZCollaborationItemStatus eZCollaborationNotificationRule eZCollaborationProfile eZCollaborationSimpleMessage eZContentBrowseBookmark eZContentBrowseRecent eZContentClass eZContentClassAttribute eZContentClassClassGroup eZContentClassGroup eZContentClassName eZContentLanguage eZContentObject eZContentObjectAttribute eZContentObjectTreeNode eZContentObjectVersion eZDiscountRule eZDiscountSubRule eZDiscountSubRuleValue eZEnumObjectValue eZEnumValue eZForgotPassword eZGeneralDigestUserSettings eZImage eZImageFile eZImageVariation eZInformationCollection eZInformationCollectionAttribute eZMedia eZNodeAssignment eZNotificationCollection eZNotificationCollectionItem eZNotificationEvent eZOperationMemento eZOrder eZOrderItem eZOrderStatus eZOrderStatusHistory eZPDFExport eZPolicy eZPolicyLimitation eZPolicyLimitationValue eZProductCategory eZProductCollection eZProductCollectionItem eZProductCollectionItemOption eZRSSExport eZRSSExportItem eZRSSImport eZSection eZSubtreeNotificationRule eZTipafriendCounter eZTipafriendRequest eZTrigger eZURL eZURLAlias eZURLObjectLink eZUser eZUserAccountKey eZUserDiscountRule eZUserSetting eZVatRule eZVatType eZViewCounter eZWaitUntilDateValue eZWishList eZWorkflow eZWorkflowEvent eZWorkflowGroup eZWorkflowGroupLink eZWorkflowProcess

List of all members.

Public Member Functions

attribute ($attr, $noFunction=false)
 attributes ()
 conditionText (&$conditions)
conditionTextByRow (&$conditions, &$row)
 definition ()
escapeArray (&$array)
 eZPersistentObject ($row)
 fetchObject (&$def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
 fetchObjectList (&$def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
 fill (&$row)
 getShortAttributeName (&$db, &$def, $attrName)
 handleRows (&$rows, $class_name, $asObject)
 hasAttribute ($attr)
 hasDirtyData ()
 newObjectOrder (&$def, $orderField, $conditions)
 remove ($conditions=null, $extraConditions=null)
 removeObject (&$def, $conditions=null, $extraConditions=null)
 reorderObject (&$def, $orderField, $conditions, $down=true)
 setAttribute ($attr, $val)
 setHasDirtyData ($hasDirtyData)
 store ($fieldFilters=null)
 swapRow ($table, &$keys, &$order_id, &$rows, $id1, $id2)
 sync ($fieldFilters=null)
 updateObjectList ($parameters)

Private Member Functions

 storeObject (&$obj, $fieldFilters=null)

Static Private Member Functions

 replaceFieldsWithShortNames (&$db, &$fieldDefs, &$fields)

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.

class MyClass extends eZPersistentObject
{
    function MyClass( $row )
    {
        $this->eZPersistentObject( $row );
    }
}

Definition at line 61 of file ezpersistentobject.php.


Member Function Documentation

& eZPersistentObject::attribute ( attr,
noFunction = false 
)
Returns:
the attribute data for $attr, this is either returned from the member variables or a member function depending on whether the definition field or function attributes matched.

Definition at line 1175 of file ezpersistentobject.php.

Referenced by eZUser::accessArray(), eZPolicy::accessArray(), eZNotificationCollection::addItem(), eZContentObject::addLocation(), eZPolicyLimitation::allValues(), eZPolicyLimitation::allValuesAsArrayWithNames(), eZPolicyLimitation::allValuesAsString(), eZContentClassGroup::appendClass(), eZURLAlias::asArray(), eZContentObject::assignedNodes(), eZContentObjectVersion::assignToNode(), eZImage::attribute(), eZProductCollectionItem::calculatePriceWithOptions(), eZSection::canBeRemoved(), eZContentObject::canEdit(), eZOrder::canModifyStatus(), eZContentObject::canTranslate(), eZContentObjectVersion::checkAccess(), eZContentObjectTreeNode::checkAccess(), eZContentObject::checkAccess(), eZContentObjectTreeNode::checkPath(), eZContentObjectTreeNode::childrenByName(), eZWaitUntilDateValue::classAttributeName(), eZContentObjectTreeNode::classListFromPolicy(), eZContentObject::classListFromPolicy(), eZWaitUntilDateValue::className(), eZURLAlias::cleanup(), eZWorkflow::cleanupWorkFlowProcess(), eZWaitUntilDateValue::clone(), eZNodeAssignment::clone(), eZEnumValue::clone(), eZContentClassAttribute::clone(), eZContentClass::clone(), eZContentObjectAttribute::collectInformation(), eZContentObject::contentActionList(), eZInformationCollectionAttribute::contentClassAttribute(), eZInformationCollectionAttribute::contentObject(), eZContentObjectVersion::contentObject(), eZInformationCollectionAttribute::contentObjectAttribute(), eZPolicyLimitationValue::copy(), eZPolicyLimitation::copy(), eZPolicy::copy(), eZContentObject::copy(), eZContentObject::copyVersion(), eZPDFExport::countGeneratingOnceExports(), eZVatRule::country(), eZURLAlias::createForForwarding(), eZContentObject::createInitialVersion(), eZContentObject::createNewVersion(), eZContentObject::createNodeAssignment(), eZCollaborationItem::createNotificationEvent(), eZBasket::createOrder(), eZInformationCollection::creator(), eZOrder::currencyCode(), eZContentObject::currentVersion(), eZContentObjectTreeNode::dataMap(), eZPDFExport::exportClassesArray(), eZNotificationEvent::eZNotificationEvent(), eZUser::failedLoginAttempts(), eZTrigger::fetchAllowedWorkflows(), eZContentObject::fetchClassAttributes(), eZContentObject::fetchDataMap(), eZContentClass::fetchGroupIDList(), eZContentClass::fetchGroupList(), eZRSSExport::fetchImageURL(), eZContentObject::fetchInput(), eZContentClass::fetchMatchGroupIDList(), eZContentBrowseRecent::fetchNode(), eZContentBrowseBookmark::fetchNode(), eZContentObjectTreeNode::fetchParent(), eZContentObjectTreeNode::fetchPath(), eZRSSExport::fetchRSS1_0(), eZRSSExport::fetchRSS2_0(), eZPDFExport::filepath(), eZURLAlias::forwardURL(), eZImageVariation::fullPath(), eZUser::generateAccessArray(), eZContentObjectTreeNode::getName(), eZNodeAssignment::getParentNode(), eZNodeAssignment::getParentObject(), eZUser::groups(), eZCollaborationItem::handler(), eZContentObjectVersion::hasConflicts(), eZUser::hasStoredLogin(), eZRSSImport::importDescription(), eZViewCounter::increase(), eZContentClass::inGroup(), eZWorkflow::ingroupIDList(), eZWorkflow::ingroupList(), eZContentClassAttribute::instantiate(), eZContentClass::instantiate(), eZContentClassAttribute::instantiateTemporary(), eZContentObject::isAlwaysAvailable(), eZUser::isAnonymous(), eZUser::isEnabled(), eZUser::isLocked(), eZNotificationCollection::itemCount(), eZNotificationCollection::items(), eZBasket::itemsInfo(), eZNotificationCollection::itemsToSend(), eZContentObjectVersion::languageMask(), eZPolicyLimitation::limitArray(), eZPolicy::limitationList(), eZUser::limitList(), eZOperationMemento::mainMemento(), eZContentObject::mainNode(), eZContentObject::mainNodeID(), eZContentObjectVersion::mainParentNodeID(), eZContentObject::mainParentNodeID(), eZMedia::mimeTypeCategory(), eZBinaryFile::mimeTypeCategory(), eZMedia::mimeTypePart(), eZBinaryFile::mimeTypePart(), eZContentObjectVersion::name(), eZContentObject::name(), eZContentObject::names(), eZSubtreeNotificationRule::node(), eZContentObjectVersion::nodeAssignments(), eZContentObjectVersion::nonTranslatableAttributesToUpdate(), eZProductCollectionItem::optionList(), eZOrder::orderItems(), eZContentObjectTrashNode::originalParent(), eZContentObjectTrashNode::originalParentPathIdentificationString(), eZWorkflowProcess::parameterList(), eZContentObjectVersion::parentNodes(), eZContentObjectTreeNode::pathArray(), eZPolicyLimitation::policy(), eZOrderItem::priceExVAT(), eZOrderItem::priceIncVAT(), eZVatRule::productCategoriesIDs(), eZVatRule::productCategoriesNames(), eZVatRule::productCategoriesString(), eZOrder::productCollection(), eZBasket::productCollection(), eZContentObjectVersion::relatedContentObjectArray(), eZContentObjectTreeNode::remoteID(), eZContentObject::remoteID(), eZContentClass::remoteID(), eZContentClass::removableInformation(), eZWorkflowProcess::remove(), eZProductCollectionItem::remove(), remove(), eZPDFExport::remove(), eZForgotPassword::remove(), eZContentObjectVersion::remove(), eZContentClassAttribute::remove(), eZContentObjectVersion::removeAssignment(), eZOrder::removeCollection(), eZBasket::removeItem(), eZContentObjectTreeNode::removeNodeFromTree(), eZContentObject::removeReverseRelations(), eZContentObjectVersion::removeTranslation(), eZContentObject::removeTranslation(), eZContentClass::removeTranslation(), eZContentObject::rename(), eZContentObjectVersion::reverseRelatedObjectList(), eZUser::roleIDList(), eZUser::roles(), eZRSSExport::rssXml(), eZWorkflowProcess::run(), eZContentObjectVersion::serialize(), eZContentObjectTreeNode::serialize(), eZContentObject::serialize(), eZContentObjectVersion::setAlwaysAvailableLanguageID(), eZContentObject::setAlwaysAvailableLanguageID(), eZContentClass::setAlwaysAvailableLanguageID(), eZCollaborationItem::setIsActive(), eZWorkflow::setIsEnabled(), eZCollaborationItem::setLastRead(), eZContentObject::setName(), eZContentClass::setName(), eZWorkflowProcess::setParameters(), eZContentObjectTreeNode::sortArray(), eZOrder::statusModificationList(), eZVatRule::store(), eZUser::store(), eZRSSExport::store(), eZPDFExport::store(), eZContentClassAttribute::store(), eZContentClassAttribute::storeDefined(), eZContentClass::storeDefined(), eZMedia::storedFileInfo(), eZBinaryFile::storedFileInfo(), eZContentObjectTreeNode::subtreeSoleNodeCount(), eZContentObjectVersion::tempMainNode(), eZNodeAssignment::tempNode(), eZContentObjectAttribute::translateTo(), eZBasket::type(), eZContentObjectVersion::unpublish(), eZContentObjectTreeNode::updateAndStoreModified(), eZBasket::updatePrices(), eZContentObjectTreeNode::updateSubTreePath(), eZContentObjectTreeNode::updateURLAlias(), eZCollaborationNotificationRule::user(), eZPolicyLimitation::valueList(), eZVatRule::vatTypeName(), eZVatRule::vatTypeObject(), eZProductCollectionItem::verify(), eZContentObject::versionLanguageName(), eZContentObjectVersion::versionName(), and eZContentObjectTreeNode::viewCount().

eZPersistentObject::attributes (  ) 
Returns:
the attributes for this object, taken from the definition fields and function attributes.

Reimplemented in eZImage, and eZWorkflowEvent.

Definition at line 1146 of file ezpersistentobject.php.

Referenced by eZWorkflowEvent::attributes().

eZPersistentObject::conditionText ( &$  conditions  ) 

Calls conditionTextByRow with an empty row and $conditions.

Definition at line 545 of file ezpersistentobject.php.

Referenced by fetchObjectList(), newObjectOrder(), removeObject(), and storeObject().

& eZPersistentObject::conditionTextByRow ( &$  conditions,
&$  row 
)

Generates an SQL sentence from the conditions $conditions and row data $row. If $row is empty (null) it uses the condition data instead of row data.

Definition at line 555 of file ezpersistentobject.php.

Referenced by conditionText(), and reorderObject().

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 eZOperationMemento, eZBinaryFile, eZEnumObjectValue, eZEnumValue, eZImage, eZImageFile, eZImageVariation, eZMedia, eZURL, eZURLObjectLink, eZForgotPassword, eZUser, eZUserAccountKey, eZUserSetting, eZBasket, eZCollaborationGroup, eZCollaborationItem, eZCollaborationItemGroupLink, eZCollaborationItemMessageLink, eZCollaborationItemParticipantLink, eZCollaborationItemStatus, eZCollaborationProfile, eZCollaborationSimpleMessage, eZContentBrowseBookmark, eZContentBrowseRecent, eZContentClass, eZContentClassAttribute, eZContentClassClassGroup, eZContentClassGroup, eZContentClassName, eZContentLanguage, eZContentObject, eZContentObjectAttribute, eZContentObjectTrashNode, eZContentObjectTreeNode, eZContentObjectVersion, eZDiscountRule, eZDiscountSubRule, eZDiscountSubRuleValue, eZInformationCollection, eZInformationCollectionAttribute, eZNodeAssignment, eZOrder, eZOrderItem, eZOrderStatus, eZOrderStatusHistory, eZPDFExport, eZPolicy, eZPolicyLimitation, eZPolicyLimitationValue, eZProductCategory, eZProductCollection, eZProductCollectionItem, eZProductCollectionItemOption, eZRSSExport, eZRSSExportItem, eZRSSImport, eZSection, eZTipafriendCounter, eZTipafriendRequest, eZTrigger, eZURLAlias, eZUserDiscountRule, eZVatRule, eZVatType, eZViewCounter, eZWishList, eZWorkflow, eZWorkflowEvent, eZWorkflowGroup, eZWorkflowGroupLink, eZWorkflowProcess, eZNotificationCollection, eZNotificationCollectionItem, eZNotificationEvent, eZCollaborationNotificationRule, eZGeneralDigestUserSettings, eZSubtreeNotificationRule, and eZWaitUntilDateValue.

Definition at line 1036 of file ezpersistentobject.php.

Referenced by attribute(), attributes(), fill(), hasAttribute(), remove(), and setAttribute().

& eZPersistentObject::escapeArray ( &$  array  ) 

Definition at line 1041 of file ezpersistentobject.php.

eZPersistentObject::eZPersistentObject ( row  ) 

Initializes the object with the row $row. It will try to set each field taken from the database row. Calls fill to do the job. If the parameter $row is an integer it will try to fetch it from the database using it as the unique ID.

Definition at line 69 of file ezpersistentobject.php.

Referenced by eZBasket::eZBasket(), eZBinaryFile::eZBinaryFile(), eZCollaborationGroup::eZCollaborationGroup(), eZCollaborationItem::eZCollaborationItem(), eZCollaborationItemGroupLink::eZCollaborationItemGroupLink(), eZCollaborationItemMessageLink::eZCollaborationItemMessageLink(), eZCollaborationItemParticipantLink::eZCollaborationItemParticipantLink(), eZCollaborationItemStatus::eZCollaborationItemStatus(), eZCollaborationNotificationRule::eZCollaborationNotificationRule(), eZCollaborationProfile::eZCollaborationProfile(), eZCollaborationSimpleMessage::eZCollaborationSimpleMessage(), eZContentBrowseBookmark::eZContentBrowseBookmark(), eZContentBrowseRecent::eZContentBrowseRecent(), eZContentClass::eZContentClass(), eZContentClassAttribute::eZContentClassAttribute(), eZContentClassClassGroup::eZContentClassClassGroup(), eZContentClassGroup::eZContentClassGroup(), eZContentClassName::eZContentClassName(), eZContentLanguage::eZContentLanguage(), eZContentObject::eZContentObject(), eZContentObjectAttribute::eZContentObjectAttribute(), eZContentObjectTrashNode::eZContentObjectTrashNode(), eZContentObjectTreeNode::eZContentObjectTreeNode(), eZContentObjectVersion::eZContentObjectVersion(), eZDiscountRule::eZDiscountRule(), eZDiscountSubRule::eZDiscountSubRule(), eZDiscountSubRuleValue::eZDiscountSubRuleValue(), eZEnumObjectValue::eZEnumObjectValue(), eZEnumValue::eZEnumValue(), eZForgotPassword::eZForgotPassword(), eZGeneralDigestUserSettings::eZGeneralDigestUserSettings(), eZImage::eZImage(), eZImageFile::eZImageFile(), eZImageVariation::eZImageVariation(), eZInformationCollection::eZInformationCollection(), eZInformationCollectionAttribute::eZInformationCollectionAttribute(), eZMedia::eZMedia(), eZNodeAssignment::eZNodeAssignment(), eZNotificationCollection::eZNotificationCollection(), eZNotificationCollectionItem::eZNotificationCollectionItem(), eZNotificationEvent::eZNotificationEvent(), eZOperationMemento::eZOperationMemento(), eZOrder::eZOrder(), eZOrderItem::eZOrderItem(), eZOrderStatus::eZOrderStatus(), eZOrderStatusHistory::eZOrderStatusHistory(), eZPDFExport::eZPDFExport(), eZPolicy::eZPolicy(), eZPolicyLimitation::eZPolicyLimitation(), eZPolicyLimitationValue::eZPolicyLimitationValue(), eZProductCategory::eZProductCategory(), eZProductCollection::eZProductCollection(), eZProductCollectionItem::eZProductCollectionItem(), eZProductCollectionItemOption::eZProductCollectionItemOption(), eZRSSExport::eZRSSExport(), eZRSSExportItem::eZRSSExportItem(), eZRSSImport::eZRSSImport(), eZSection::eZSection(), eZSubtreeNotificationRule::eZSubtreeNotificationRule(), eZTipafriendCounter::eZTipafriendCounter(), eZTipafriendRequest::eZTipafriendRequest(), eZTrigger::eZTrigger(), eZURL::eZURL(), eZURLAlias::eZURLAlias(), eZURLObjectLink::eZURLObjectLink(), eZUser::eZUser(), eZUserAccountKey::eZUserAccountKey(), eZUserDiscountRule::eZUserDiscountRule(), eZUserSetting::eZUserSetting(), eZVatRule::eZVatRule(), eZVatType::eZVatType(), eZViewCounter::eZViewCounter(), eZWaitUntilDateValue::eZWaitUntilDateValue(), eZWishList::eZWishList(), eZWorkflow::eZWorkflow(), eZWorkflowEvent::eZWorkflowEvent(), eZWorkflowGroup::eZWorkflowGroup(), eZWorkflowGroupLink::eZWorkflowGroupLink(), and eZWorkflowProcess::eZWorkflowProcess().

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.

See fetchObjectList() for a full description of the input parameters.

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 149 of file ezpersistentobject.php.

Referenced by eZContentObjectAttribute::clone(), eZWorkflowProcess::fetch(), eZWorkflowGroupLink::fetch(), eZWorkflowGroup::fetch(), eZWorkflowEvent::fetch(), eZWorkflow::fetch(), eZWaitUntilDateValue::fetch(), eZViewCounter::fetch(), eZVatType::fetch(), eZVatRule::fetch(), eZUserSetting::fetch(), eZUserDiscountRule::fetch(), eZUser::fetch(), eZURLObjectLink::fetch(), eZURLAlias::fetch(), eZURL::fetch(), eZTrigger::fetch(), eZTipafriendCounter::fetch(), eZSection::fetch(), eZRSSImport::fetch(), eZRSSExportItem::fetch(), eZRSSExport::fetch(), eZProductCollectionItem::fetch(), eZProductCollection::fetch(), eZProductCategory::fetch(), eZPolicy::fetch(), eZPDFExport::fetch(), eZOrderStatusHistory::fetch(), eZOrderStatus::fetch(), eZOrder::fetch(), eZOperationMemento::fetch(), eZNotificationEvent::fetch(), eZNodeAssignment::fetch(), eZMedia::fetch(), eZInformationCollection::fetch(), eZImage::fetch(), eZEnumValue::fetch(), eZEnumObjectValue::fetch(), eZDiscountSubRule::fetch(), eZDiscountRule::fetch(), eZContentObjectVersion::fetch(), eZContentObjectAttribute::fetch(), eZContentClassGroup::fetch(), eZContentClassClassGroup::fetch(), eZContentClassAttribute::fetch(), eZContentBrowseRecent::fetch(), eZContentBrowseBookmark::fetch(), eZCollaborationSimpleMessage::fetch(), eZCollaborationProfile::fetch(), eZCollaborationItemStatus::fetch(), eZCollaborationItemParticipantLink::fetch(), eZCollaborationItemMessageLink::fetch(), eZCollaborationItemGroupLink::fetch(), eZCollaborationItem::fetch(), eZCollaborationGroup::fetch(), eZBinaryFile::fetch(), eZBasket::fetch(), eZContentObjectAttribute::fetchByClassAttributeID(), eZURLAlias::fetchByDestinationURL(), eZUser::fetchByEmail(), eZBinaryFile::fetchByFileName(), eZImageFile::fetchByFilepath(), eZNodeAssignment::fetchByID(), eZPolicyLimitation::fetchByIdentifier(), eZContentObjectAttribute::fetchByIdentifier(), eZUserAccountKey::fetchByKey(), eZForgotPassword::fetchByKey(), eZUser::fetchByName(), eZRSSExport::fetchByName(), eZProductCategory::fetchByName(), eZContentClassGroup::fetchByName(), eZInformationCollectionAttribute::fetchByObjectAttributeID(), eZURLAlias::fetchBySourceURL(), eZOrderStatus::fetchByStatus(), eZCollaborationProfile::fetchByUser(), eZInformationCollection::fetchByUserIdentifier(), eZOperationMemento::fetchChild(), eZNotificationCollection::fetchForHandler(), eZGeneralDigestUserSettings::fetchForUser(), eZOperationMemento::fetchMain(), eZHTTPHeader::headerOverrideArray(), eZContentObjectPackageHandler::installSuspendedNodeAssignment(), eZContentObjectAttribute::language(), eZNodeAssignment::remove(), eZPolicy::role(), eZTrigger::runTrigger(), and eZContentObjectTreeNode::unserialize().

eZPersistentObject::fetchObjectList ( &$  def,
field_filters = null,
conds = null,
sorts = null,
limit = null,
asObject = true,
grouping = false,
custom_fields = null,
custom_tables = null,
custom_conds = 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 A definition array of all fields, table name and sorting
$field_filters If defined determines the fields which are extracted (array of field names), if not all fields are fetched
$conds null for no special condition or an associative array of fields to filter on. Syntax is FIELD => CONDITION, CONDITION can be one of:

  • Scalar value - Creates a condition where FIELD must match the value, e.g
     array( 'id' => 5 ) 
    
    generates SQL
     id = 5 
    
  • Array with two scalar values - Element 0 is the match operator and element 1 is the scalar value
     array( 'priority' => array( '>', 5 ) ) 
    
    generates SQL
     priority > 5 
    
  • Array with range - Element 1 is an array with start and stop of range in array
     array( 'type' => array( false, array( 1, 5 ) ) ) 
    
    generates SQL
     type BETWEEN 1 AND 5 
    
  • Array with multiple elements - Element 0 is an array with scalar values
     array( 'id' => array( array( 1, 5, 7 ) ) ) 
    
    generates SQL
     id IN ( 1, 5, 7 ) 
    
$sorts An associative array of sorting conditions, if set to false ignores settings in $def, if set to null uses settingss in $def. Syntax is FIELD => DIRECTION. DIRECTION must either be string 'asc' for ascending or 'desc' for descending.
$limit An associative array with limitiations, can contain

  • offset - Numerical value defining the start offset for the fetch
  • length - Numerical value defining the max number of items to return
$asObject If true then it will return an array with objects, objects are created from class defined in $def. If false it will just return the rows fetch from database.
$grouping An array of fields to group by or null to use grouping in defintion $def.
$custom_fields Array of FIELD elements to add to SQL, can be used to perform custom fetches, e.g counts. FIELD is an associative array containing:

  • operation - A text field which is included in the field list
  • name - If present it adds 'AS name' to the operation.
$custom_tables Array of additional tables.
$custom_conds String with sql conditions for 'WHERE' clause.

A full example:

     $filter = array( 'id', 'name' );
     $conds = array( 'type' => 5,
                     'size' => array( false, array( 200, 500 ) ) );
     $sorts = array( 'name' => 'asc' );
     $limit = array( 'offset' => 50, 'length' => 10 );
     eZPersistentObject::fetchObjectList( $def, $filter, $conds, $sorts, $limit, true, false, null )

Counting number of elements.

     $custom = array( array( 'operation' => 'count( id )',
                             'name' => 'count' ) );
     // Here $field_filters is set to an empty array, that way only count is used in fields
     $rows = eZPersistentObject::fetchObjectList( $def, array(), null, null, null, false, false, $custom );
     return $rows[0]['count'];

Counting elements per type using grouping

     $custom = array( array( 'operation' => 'count( id )',
                             'name' => 'count' ) );
     $group = array( 'type' );
     $rows = eZPersistentObject::fetchObjectList( $def, array(), null, null, null, false, $group, $custom );
     return $rows[0]['count'];

Example to fetch a result with custom conditions. The following example will fetch the attributes to the contentobject with id 1 and add the contentobject.name in each attribute row with the array key contentobject_name.

     $objectDef = eZContentObject::definition();
     $objectAttributeDef = eZContentObjectAttribute::definition();

     $fields = array();
     $conds = array( $objectDef['name'] . '.id' => 1 );
     $sorts = array( $objectAttributeDef['name'] . '.sort_key_string' => 'asc' );

     $limit = null;
     $asObject = false;
     $group = false;

     $customFields = array( $objectAttributeDef['name'] . '.*',
                             array( 'operation' => $objectDef['name'] . '.name',
                                    'name' => 'contentobject_name' ) );

     $customTables = array( $objectDef['name'] );

     $languageCode = 'eng-GB';
     $customConds = ' AND ' . $objectDef['name'] . '.current_version=' . $objectAttributeDef['name'] . '.version' .
                     ' AND ' . $objectDef['name'] . '.id=' . $objectAttributeDef['name'] . '.contentobject_id' .
                     ' AND ' . $objectAttributeDef['name'] . '.language_code=\'' . $languageCode . '\'';

     $rows = eZPersistentObject::fetchObjectList( $objectAttributeDef, $fields, $conds, $sorts, $limit, $asObject,
                                                  $group, $customFields, $customTables, $customConds );

Definition at line 728 of file ezpersistentobject.php.

Referenced by eZOrder::active(), eZOrder::activeByUserID(), eZContentObject::allContentObjectAttributes(), eZMultiplexerType::attribute(), eZSection::canBeRemoved(), eZSSLZone::checkNodeID(), eZSSLZone::checkObject(), eZContentClassClassGroup::classInGroup(), eZURLObjectLink::clearCacheForObjectLink(), eZPDFExport::countGeneratingOnceExports(), eZContentBrowseRecent::createNew(), eZBasket::currentBasket(), eZWishList::currentWishList(), eZContentClass::exists(), eZMedia::fetch(), eZImage::fetch(), eZContentClass::fetch(), eZBinaryFile::fetch(), eZRSSImport::fetchActiveList(), eZUserSetting::fetchAll(), eZWaitUntilDateValue::fetchAllElements(), eZEnumValue::fetchAllElements(), eZEnumObjectValue::fetchAllElements(), eZContentObjectAttribute::fetchAttributeTranslations(), eZContentObjectTreeNode::fetchByContentObjectID(), eZNotificationCollectionItem::fetchByDate(), eZBinaryFile::fetchByFileName(), eZContentClass::fetchByIdentifier(), eZURLAlias::fetchByOffset(), eZSection::fetchByOffset(), eZPolicyLimitation::fetchByPolicyID(), eZContentClass::fetchByRemoteID(), eZUserDiscountRule::fetchByRuleID(), eZDiscountSubRule::fetchByRuleID(), eZDiscountSubRuleValue::fetchBySubRuleID(), eZUserDiscountRule::fetchByUserID(), eZVatRule::fetchByVatType(), eZContentClassClassGroup::fetchClassListByGroups(), eZInformationCollection::fetchCollectionsCount(), eZInformationCollection::fetchCollectionsList(), eZVatRule::fetchCountByVatType(), eZNotificationCollectionItem::fetchCountForEvent(), eZWorkflow::fetchEventCount(), eZWorkflow::fetchEventIndexed(), eZContentObjectVersion::fetchFiltered(), eZWorkflowEvent::fetchFilteredList(), eZSection::fetchFilteredList(), eZRSSExportItem::fetchFilteredList(), eZContentObject::fetchFilteredList(), eZContentClassAttribute::fetchFilteredList(), eZWorkflowProcess::fetchForContent(), eZImageFile::fetchForContentObjectAttribute(), eZNodeAssignment::fetchForObject(), eZWorkflowProcess::fetchForSession(), eZWorkflowProcess::fetchForStatus(), eZContentObjectVersion::fetchForUser(), eZWorkflowGroupLink::fetchGroupList(), eZContentClassClassGroup::fetchGroupList(), eZCollaborationItemMessageLink::fetchItemCount(), eZCollaborationItemMessageLink::fetchItemList(), eZCollaborationNotificationRule::fetchItemTypeList(), eZURLObjectLink::fetchLinkList(), eZWorkflowProcess::fetchList(), eZWorkflowGroup::fetchList(), eZWorkflowEvent::fetchList(), eZWorkflow::fetchList(), eZVatType::fetchList(), eZVatRule::fetchList(), eZTrigger::fetchList(), eZSubtreeNotificationRule::fetchList(), eZSection::fetchList(), eZRSSImport::fetchList(), eZRSSExport::fetchList(), eZProductCollectionItemOption::fetchList(), eZProductCollectionItem::fetchList(), eZProductCategory::fetchList(), eZPolicyLimitationValue::fetchList(), eZPDFExport::fetchList(), eZOrderStatus::fetchList(), eZOrderItem::fetchList(), eZOrder::fetchList(), eZOperationMemento::fetchList(), eZNotificationEvent::fetchList(), eZImage::fetchList(), eZDiscountSubRuleValue::fetchList(), eZDiscountSubRule::fetchList(), eZDiscountRule::fetchList(), eZContentObject::fetchList(), eZContentLanguage::fetchList(), eZContentClassName::fetchList(), eZContentClassGroup::fetchList(), eZContentClassAttribute::fetchList(), eZContentClass::fetchList(), eZCollaborationNotificationRule::fetchList(), eZCollaborationItemGroupLink::fetchList(), eZContentObjectAttribute::fetchListByClassID(), eZContentClassAttribute::fetchListByClassID(), eZNodeAssignment::fetchListByID(), eZWorkflowProcess::fetchListByKey(), eZOrderItem::fetchListByType(), eZWorkflowProcess::fetchListCount(), eZWorkflow::fetchListCount(), eZSubtreeNotificationRule::fetchListCount(), eZContentObject::fetchListCount(), eZNotificationCollection::fetchListForHandler(), eZContentBrowseRecent::fetchListForUser(), eZContentBrowseBookmark::fetchListForUser(), eZOrderStatus::fetchMap(), eZSubtreeNotificationRule::fetchNodesForUserID(), fetchObject(), eZURLObjectLink::fetchObjectVersionCount(), eZURLObjectLink::fetchObjectVersionList(), eZOrderStatus::fetchOrderedList(), eZCollaborationItemParticipantLink::fetchParticipantList(), eZContentObjectAttribute::fetchSameClassAttributeIDList(), eZContentObject::fetchSameClassListCount(), eZViewCounter::fetchTopList(), eZNotificationEvent::fetchUnhandledList(), eZContentObjectVersion::fetchUserDraft(), eZUserDiscountRule::fetchUserID(), eZWorkflowProcess::fetchUserList(), eZGeneralDigestHandler::fetchUsersForDigest(), eZImageVariation::fetchVariation(), eZContentObjectVersion::fetchVersion(), eZURLAlias::fetchWildcards(), eZWorkflowGroupLink::fetchWorkflowList(), eZURL::handleList(), eZWishList::itemCount(), eZNotificationCollection::itemCount(), eZProductCollection::itemList(), eZWishList::items(), eZNotificationCollection::items(), eZBasket::items(), eZNotificationCollection::itemsToSend(), eZPolicy::limitationList(), eZOrder::productItems(), eZObjectRelationListType::removeRelationObject(), reorderObject(), storeObject(), eZPolicyLimitation::valueList(), eZProductCollection::verify(), and 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 83 of file ezpersistentobject.php.

Referenced by eZPersistentObject().

eZPersistentObject::getShortAttributeName ( &$  db,
&$  def,
attrName 
)
Returns:
short attribute name (alias) if it's defined, given attribute name otherwise

Definition at line 1277 of file ezpersistentobject.php.

Referenced by eZURL::handleList().

eZPersistentObject::handleRows ( &$  rows,
class_name,
asObject 
)

Creates PHP objects out of the database rows $rows. Each object is created from class $ class_name and is passed as a row array as parameter.

Parameters:
$asObject If true then objects will be created, if not it just returns $rows as it is.

Definition at line 876 of file ezpersistentobject.php.

Referenced by eZContentObjectTreeNode::canCreateClassList(), eZContentObject::canCreateClassList(), eZContentClass::canInstantiateClassList(), eZContentClass::fetchAllClasses(), eZContentClassClassGroup::fetchClassList(), eZOrderStatusHistory::fetchListByOrder(), eZCollaborationItem::fetchListTool(), fetchObjectList(), eZUser::fetchUserClassList(), and eZCollaborationGroup::subTree().

eZPersistentObject::hasAttribute ( attr  ) 
Returns:
true if the attribute $attr is part of the definition fields or function attributes.

Reimplemented in eZImage, and eZWorkflowEvent.

Definition at line 1160 of file ezpersistentobject.php.

Referenced by eZWorkflowProcess::run().

eZPersistentObject::hasDirtyData (  ) 
Returns:
true if the data is considered dirty and needs to be stored.
See also:
sync

Definition at line 1260 of file ezpersistentobject.php.

Referenced by sync(), and eZContentClass::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 919 of file ezpersistentobject.php.

Referenced by eZWorkflowEvent::create(), eZEnumValue::create(), and eZContentClassAttribute::create().

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.

Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Reimplemented in eZBinaryFile, eZEnumValue, eZImage, eZMedia, eZContentClass, eZContentClassName, eZContentObject, eZContentObjectAttribute, eZNodeAssignment, and eZWaitUntilDateValue.

Definition at line 178 of file ezpersistentobject.php.

Referenced by eZUser::removeUser().

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.

Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Definition at line 202 of file ezpersistentobject.php.

Referenced by eZXMLTextType::deleteStoredObjectAttribute(), eZSubTreeHandler::fetchHttpInput(), eZGeneralDigestHandler::handle(), eZContentObject::purge(), eZWorkflowProcess::remove(), eZWorkflowGroupLink::remove(), eZWorkflow::remove(), eZWaitUntilDateValue::remove(), eZViewCounter::remove(), eZVatType::remove(), eZVatRule::remove(), eZUserSetting::remove(), eZUserDiscountRule::remove(), eZUserAccountKey::remove(), eZSection::remove(), eZProductCategory::remove(), remove(), eZOrderStatus::remove(), eZMedia::remove(), eZImage::remove(), eZForgotPassword::remove(), eZEnumValue::remove(), eZEnumObjectValue::remove(), eZDiscountSubRuleValue::remove(), eZDiscountSubRule::remove(), eZDiscountRule::remove(), eZContentObjectAttribute::remove(), eZContentObject::remove(), eZContentClassClassGroup::remove(), eZBinaryFile::remove(), eZWaitUntilDateValue::removeAllElements(), eZEnumValue::removeAllElements(), eZEnumObjectValue::removeAllElements(), eZContentClass::removeAttributes(), eZURL::removeByID(), eZCollaborationNotificationRule::removeByIdentifier(), eZSubtreeNotificationRule::removeByNodeAndUserID(), eZDiscountSubRuleValue::removeBySubRuleID(), eZWishList::removeByUserID(), eZSubtreeNotificationRule::removeByUserID(), eZCollaborationNotificationRule::removeByUserID(), eZPolicyLimitationValue::removeByValue(), eZContentClassClassGroup::removeClassMembers(), eZNotificationCollection::removeEmpty(), eZWorkflow::removeEvents(), eZTipafriendCounter::removeForNode(), eZWorkflowGroupLink::removeGroupMembers(), eZContentClassClassGroup::removeGroupMembers(), eZWorkflowGroup::removeSelected(), eZPolicyLimitation::removeSelected(), eZContentClassGroup::removeSelected(), eZWorkflow::removeTemporary(), eZContentClass::removeTemporary(), eZURLObjectLink::removeURLlinkList(), eZUserDiscountRule::removeUser(), eZUser::removeUser(), eZImageVariation::removeVariation(), eZWorkflow::removeWorkflow(), and eZWorkflowGroupLink::removeWorkflowMembers().

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
Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
Parameters:
orderField Associative array with one element, the key is the order id and values is order value.

Definition at line 944 of file ezpersistentobject.php.

Referenced by eZWorkflowEvent::move(), and eZContentClassAttribute::move().

eZPersistentObject::replaceFieldsWithShortNames ( &$  db,
&$  fieldDefs,
&$  fields 
) [static, private]

For the given array fields treats its keys (for associative array) or values (for non-associative array) as table fields names and replaces them with short names (aliases) found in fieldDefs.

Definition at line 108 of file ezpersistentobject.php.

Referenced by fetchObjectList(), removeObject(), and storeObject().

eZPersistentObject::setAttribute ( attr,
val 
)
eZPersistentObject::setHasDirtyData ( hasDirtyData  ) 

Sets whether the object has dirty data or not.

See also:
hasDirtyData, sync

Definition at line 1269 of file ezpersistentobject.php.

Referenced by setAttribute().

eZPersistentObject::store ( fieldFilters = null  ) 

Stores the object in the database, uses storeObject() to do the actual job and passes $fieldFilters to it.

Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Reimplemented in eZPDFExport, eZRSSExport, and eZWorkflow.

Definition at line 232 of file ezpersistentobject.php.

Referenced by eZOrder::activate(), eZBasket::createOrder(), eZOrder::detachProductCollection(), eZViewCounter::increase(), eZOrder::modifyStatus(), eZOrderStatus::storeCustom(), sync(), and eZContentObjectVersion::updateLanguageMask().

eZPersistentObject::storeObject ( &$  obj,
fieldFilters = null 
) [private]

Stores the data in $obj to database.

Parameters:
fieldFilters If specified only certain fields will be stored.
Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Definition at line 256 of file ezpersistentobject.php.

Referenced by store().

eZPersistentObject::swapRow ( table,
&$  keys,
&$  order_id,
&$  rows,
id1,
id2 
)

Sets row id $id2 to have the placement of row id $id1.

Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Definition at line 899 of file ezpersistentobject.php.

Referenced by reorderObject().

eZPersistentObject::sync ( fieldFilters = null  ) 

Makes sure data is stored if the data is considered dirty.

See also:
hasDirtyData
Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Reimplemented in eZContentClass.

Definition at line 243 of file ezpersistentobject.php.

Referenced by eZContentObjectTreeNode::remoteID(), and eZContentObject::remoteID().

eZPersistentObject::updateObjectList ( parameters  ) 
Note:
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Definition at line 1067 of file ezpersistentobject.php.

Referenced by eZWorkflow::setIsEnabled(), eZURL::setIsValid(), eZURL::setLastChecked(), eZContentClassClassGroup::update(), and eZCollaborationItemStatus::updateFields().


Member Data Documentation

eZPersistentObject::$PersistentDataDirty [private]

Whether the data is dirty, ie needs to be stored, or not.

Definition at line 1289 of file ezpersistentobject.php.


The documentation for this class was generated from the following file:
Generated on Mon Jul 12 07:10:30 2010 for eZ publish by  doxygen 1.6.3