Doctrine_Record::free PHP Метод

free() публичный Метод

Cuts all references the entity has to other entities and removes the entity from the instance pool. Note: The entity is no longer useable after free() has been called. Any operations done with the entity afterwards can lead to unpredictable results.
public free ( boolean $deep = false )
$deep boolean whether to free also the related components
    public function free($deep = false)
    {
        if ($this->_state != self::STATE_LOCKED && $this->_state != self::STATE_TLOCKED) {
            $this->_state = $this->exists() ? self::STATE_LOCKED : self::STATE_TLOCKED;
            $this->_table->getRepository()->evict($this->_oid);
            $this->_table->removeRecord($this);
            $this->_data = array();
            $this->_id = array();
            if ($deep) {
                foreach ($this->_references as $name => $reference) {
                    if (!$reference instanceof Doctrine_Null) {
                        $reference->free($deep);
                    }
                }
            }
            $this->_references = array();
        }
    }

Usage Example

Пример #1
0
 /**
  * Frees the resources used by the collection.
  * WARNING: After invoking free() the collection is no longer considered to
  * be in a useable state. Subsequent usage may result in unexpected behavior.
  *
  * @return void
  */
 public function free($deep = false)
 {
     foreach ($this->getData() as $key => $record) {
         if (!$record instanceof Doctrine_Null) {
             $record->free($deep);
         }
     }
     $this->data = array();
     if ($this->reference) {
         $this->reference->free($deep);
         $this->reference = null;
     }
 }