Changeset 3879

Show
Ignore:
Timestamp:
02/21/08 18:42:01 (17 months ago)
Author:
romanb
Message:

Added Doctrine_Record::free() from trunk that can help with controlling memory usage and improved the hydration for large result sets by reducing the number of getTypeOf() calls.

Location:
branches/0.10/lib/Doctrine
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Hydrator.php

    r3755 r3879  
    300300                    $cache[$key]['isSimpleType'] = true; 
    301301                } else { 
     302                    $cache[$key]['type'] = $type; 
    302303                    $cache[$key]['isSimpleType'] = false; 
    303304                } 
     
    320321                $rowData[$dqlAlias][$fieldName] = $value; 
    321322            } else { 
    322                 $rowData[$dqlAlias][$fieldName] = $table->prepareValue($fieldName, $value); 
     323                $rowData[$dqlAlias][$fieldName] = $table->prepareValue( 
     324                        $fieldName, $value, $cache[$key]['type']); 
    323325            } 
    324326 
  • branches/0.10/lib/Doctrine/Record.php

    r3708 r3879  
    18161816        $this->getNode()->delete(); 
    18171817    } 
     1818     
     1819    /** 
     1820     * Helps freeing the memory occupied by the entity. 
     1821     * Cuts all references the entity has to other entities and removes the entity 
     1822     * from the instance pool. 
     1823     * Note: The entity is no longer useable after free() has been called. Any operations 
     1824     * done with the entity afterwards can lead to unpredictable results. 
     1825     */ 
     1826    public function free() 
     1827    { 
     1828        $this->_table->getRepository()->evict($this->_oid); 
     1829        $this->_table->removeRecord($this); 
     1830        $this->_data = array(); 
     1831        $this->_id = array(); 
     1832        $this->_references = array(); 
     1833    } 
     1834     
    18181835    public function toString() 
    18191836    { 
  • branches/0.10/lib/Doctrine/Table.php

    r3798 r3879  
    16391639     * @param string $field     the name of the field 
    16401640     * @param string $value     field value 
     1641     * @param string $typeHint  Type hint used to pass in the type of the value to prepare 
     1642     *                          if it is already known. This enables the method to skip 
     1643     *                          the type determination. Used i.e. during hydration. 
    16411644     * @return mixed            prepared value 
    16421645     */ 
    1643     public function prepareValue($fieldName, $value) 
     1646    public function prepareValue($fieldName, $value, $typeHint = null) 
    16441647    { 
    16451648        if ($value === self::$_null) { 
     
    16481651            return null; 
    16491652        } else { 
    1650             $type = $this->getTypeOf($fieldName); 
     1653            $type = is_null($typeHint) ? $this->getTypeOf($fieldName) : $typeHint; 
    16511654 
    16521655            switch ($type) {