Changeset 3123

Show
Ignore:
Timestamp:
04/15/08 08:09:12 (3 months ago)
Author:
pmjones
Message:

Solar_Sql_Model_Record

* [CHG] Now that Solar_Filter only loops through filter keys, not every single data key regardless of whether or not it has filters on it, the lazy-load flag is no longer needed.

* [ADD] Method load() now adds placeholders for calculate-cols.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Solar/Sql/Model/Record.php

    r3091 r3123  
    9494    /** 
    9595     *  
    96      * Tells whether or not __get() should lazy-load relateds. 
    97      *  
    98      * We need this so that when saving, we don't load every related record. 
    99      *  
    100      * @var bool 
    101      *  
    102      */ 
    103     protected $_lazy_load = true; 
    104      
    105     /** 
    106      *  
    10796     * If you call save() and an exception gets thrown, this stores that 
    10897     * exception. 
     
    151140         
    152141        // do we need to load relationship data? 
    153         $load_related = $this->_lazy_load && 
    154                         empty($this->_data[$key]) && 
     142        $load_related = empty($this->_data[$key]) && 
    155143                        ! empty($this->_model->related[$key]); 
    156144         
     
    379367        } 
    380368         
     369        // set placeholders for calculate cols 
     370        foreach ((array) $this->_model->calculate_cols as $col) { 
     371            if (! array_key_exists($col, $this->_data)) { 
     372                $this->_data[$col] = null; 
     373            } 
     374        } 
     375         
    381376        // set all remaining values in the load 
    382377        foreach ($load as $key => $val) { 
    383378            $this->__set($key, $val); 
    384379        } 
    385          
    386380    } 
    387381     
     
    10391033        $filter->setChainLocaleObject($this->_model); 
    10401034         
    1041         // turn off lazy-loading while applying filters to make sure we don't 
    1042         // get recursive behavior 
    1043         $this->_lazy_load = false; 
     1035        // apply filters 
    10441036        $valid = $filter->applyChain($this); 
    1045         $this->_lazy_load = true; 
    10461037         
    10471038        // retain invalids