本文整理汇总了PHP中Doctrine_Record::refreshRelated方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::refreshRelated方法的具体用法?PHP Doctrine_Record::refreshRelated怎么用?PHP Doctrine_Record::refreshRelated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::refreshRelated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _cascadeDelete
/**
* Cascades an ongoing delete operation to related objects. Applies only on relations
* that have 'delete' in their cascade options.
* This is an application-level cascade. Related objects that participate in the
* cascade and are not yet loaded are fetched from the database.
* Exception: many-valued relations are always (re-)fetched from the database to
* make sure we have all of them.
*
* @param Doctrine_Record The record for which the delete operation will be cascaded.
* @throws PDOException If something went wrong at database level
* @return void
*/
protected function _cascadeDelete(Doctrine_Record $record, array &$deletions)
{
foreach ($record->getTable()->getRelations() as $relation) {
if ($relation->isCascadeDelete()) {
$fieldName = $relation->getAlias();
// if it's a xToOne relation and the related object is already loaded
// we don't need to refresh.
if (!($relation->getType() == Doctrine_Relation::ONE && isset($record->{$fieldName}))) {
$record->refreshRelated($relation->getAlias());
}
$relatedObjects = $record->get($relation->getAlias());
if ($relatedObjects instanceof Doctrine_Record && $relatedObjects->exists() && !isset($deletions[$relatedObjects->getOid()])) {
$this->_collectDeletions($relatedObjects, $deletions);
} else {
if ($relatedObjects instanceof Doctrine_Collection && count($relatedObjects) > 0) {
// cascade the delete to the other objects
foreach ($relatedObjects as $object) {
if (!isset($deletions[$object->getOid()])) {
$this->_collectDeletions($object, $deletions);
}
}
}
}
}
}
}
示例2: cascade
/**
* @see Doctrine_Connection_UnitOfWork::_cascadeDelete()
* (most part copy&past from)
*
* @param Doctrine_Record The record for which the delete operation will be cascaded.
* @throws PDOException If something went wrong at database level
* @return null
*/
protected function cascade(Doctrine_Record $record)
{
foreach ($record->getTable()->getRelations() as $relation) {
/* @var $relation Doctrine_Relation_LocalKey */
# build-in Doctrine cascade mechanism do all the work - skip
if ($relation->isCascadeDelete()) {
continue;
}
$cascade = $relation->offsetGet('cascade');
# no instructions, no results - skip
if (0 == count($cascade)) {
continue;
}
$isCascadeDeleteTags = in_array('deleteTags', $cascade);
$isCascadeInvalidateTags = in_array('invalidateTags', $cascade);
# could be only 1 selected, otherwise skip
if (!($isCascadeDeleteTags xor $isCascadeInvalidateTags)) {
continue;
}
if ($isCascadeDeleteTags) {
$definitions =& $this->tagNamesToDelete;
} else {
$definitions =& $this->tagNamesToInvalidate;
}
$fieldName = $relation->getAlias();
if ($relation->getType() != Doctrine_Relation::ONE || isset($record->{$fieldName})) {
$record->refreshRelated($relation->getAlias());
}
$relatedObjects = $record->get($relation->getAlias());
if ($relatedObjects instanceof Doctrine_Record && $relatedObjects->exists() && !isset($definitions[$relatedObjects->getOid()])) {
# invalidate collection version too
$collectionName = sfCacheTaggingToolkit::obtainCollectionName($relatedObjects->getTable());
if ($isCascadeDeleteTags) {
$this->tagNamesToInvalidate[$collectionName] = $collectionName;
} elseif ($isCascadeInvalidateTags) {
$template = $relatedObjects->getTable()->getTemplate(sfCacheTaggingToolkit::TEMPLATE_NAME);
if ($template->getOption('invalidateCollectionVersionOnUpdate')) {
$this->tagNamesToInvalidate[$collectionName] = $collectionName;
}
}
$this->collect($relatedObjects, $definitions);
continue;
}
if (!$relatedObjects instanceof Doctrine_Collection || count($relatedObjects) == 0 || !$relatedObjects->getTable()->hasTemplate(sfCacheTaggingToolkit::TEMPLATE_NAME)) {
continue;
}
# invalidate collection version too
$collectionName = sfCacheTaggingToolkit::obtainCollectionName($relatedObjects->getTable());
if ($isCascadeDeleteTags) {
$this->tagNamesToInvalidate[$collectionName] = $collectionName;
} elseif ($isCascadeInvalidateTags) {
$template = $relatedObjects->getTable()->getTemplate(sfCacheTaggingToolkit::TEMPLATE_NAME);
if ($template->getOption('invalidateCollectionVersionOnUpdate')) {
$this->tagNamesToInvalidate[$collectionName] = $collectionName;
}
}
foreach ($relatedObjects as $object) {
if (isset($definitions[$object->getOid()])) {
continue;
}
$this->collect($object, $definitions);
}
}
}