示例#1
0
 /**
  * Reload all already loaded nodes to sync them with updated db
  *
  * @param      ChildCategory $prune        Object to prune from the update
  * @param      ConnectionInterface $con        Connection to use.
  */
 public static function updateLoadedNodes($prune = null, ConnectionInterface $con = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         $keys = array();
         /** @var $obj ChildCategory */
         foreach (CategoryTableMap::$instances as $obj) {
             if (!$prune || !$prune->equals($obj)) {
                 $keys[] = $obj->getPrimaryKey();
             }
         }
         if (!empty($keys)) {
             // We don't need to alter the object instance pool; we're just modifying these ones
             // already in the pool.
             $criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
             $criteria->add(CategoryTableMap::COL_CATEGORY_ID, $keys, Criteria::IN);
             $dataFetcher = ChildCategoryQuery::create(null, $criteria)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
             while ($row = $dataFetcher->fetch()) {
                 $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0);
                 /** @var $object ChildCategory */
                 if (null !== ($object = CategoryTableMap::getInstanceFromPool($key))) {
                     $object->setLeftValue($row[7]);
                     $object->setRightValue($row[8]);
                     $object->setLevel($row[9]);
                     $object->clearNestedSetChildren();
                 }
             }
             $dataFetcher->close();
         }
     }
 }