当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Record::refreshRelated方法代码示例

本文整理汇总了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);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:38,代码来源:UnitOfWork.php

示例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);
         }
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:72,代码来源:CachetaggableUnitOfWork.php


注:本文中的Doctrine_Record::refreshRelated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。