Changeset 2915

Show
Ignore:
Timestamp:
06/25/2008 06:16:17 PM (4 months ago)
Author:
Shadowhand
Message:

Optimizations to ORM

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/ORM.php

    r2899 r2915  
    292292                { 
    293293                        // Make a find_related call 
    294                         return $this->call_find_related($method, $args); 
    295                 } 
    296  
    297                 if (preg_match('/^(has|add|remove)_(.+)/', $method, $matches)) 
     294                        return $this->call_find_related(substr($method, 13), $args); 
     295                } 
     296 
     297                if (preg_match('/^(has|add|remove)_(.+)$/', $method, $matches)) 
    298298                { 
    299299                        if (empty($this->object->id)) 
     
    423423         * @return  object 
    424424         */ 
    425         protected function call_find_related($method, $args) 
    426         { 
    427                 // Extract table name 
    428                 $table = substr($method, 13); 
    429  
     425        protected function call_find_related($table, $args) 
     426        { 
    430427                // Construct a new model 
    431428                $model = $this->load_model($table); 
     
    485482        { 
    486483                $action = $matches[1]; 
    487                 $model  = is_object(current($args)) ? current($args) : $this->load_model($matches[2]); 
     484                $model  = (count($args) > 0 AND is_object($args[0])) ? $args[0] : $this->load_model($matches[2]); 
    488485 
    489486                // Real foreign table name