Example #1
0
 /**
  * Reload all already loaded nodes to sync them with updated db
  *
  * @param      Page $prune		Object to prune from the update
  * @param      PropelPDO $con		Connection to use.
  */
 public static function updateLoadedNodes($prune = null, PropelPDO $con = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         $keys = array();
         foreach (PagePeer::$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(PagePeer::DATABASE_NAME);
             $criteria->add(PagePeer::ID, $keys, Criteria::IN);
             $stmt = PagePeer::doSelectStmt($criteria, $con);
             while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
                 $key = PagePeer::getPrimaryKeyHashFromRow($row, 0);
                 if (null !== ($object = PagePeer::getInstanceFromPool($key))) {
                     $object->setLeftValue($row[10]);
                     $object->setRightValue($row[11]);
                     $object->setLevel($row[12]);
                     $object->clearNestedSetChildren();
                 }
             }
             $stmt->closeCursor();
         }
     }
 }