Changeset 1665

Show
Ignore:
Timestamp:
01/02/2008 05:16:56 PM (12 months ago)
Author:
Shadowhand
Message:

Reverting ORM::find back to find($id, $return = FALSE).

A couple of small optimizations added.

Files:
1 modified

Legend:

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

    r1662 r1665  
    106106                        { 
    107107                                // Query and load object 
    108                                 $this->find($id, FALSE); 
     108                                $this->find($id); 
    109109                        } 
    110110                } 
     
    242242                        } 
    243243 
    244                         // Find requested objects 
    245                         if (isset($all))  
    246                         { 
    247                                 // return array of results 
     244                        if (isset($all)) 
     245                        { 
     246                                // Array of results 
    248247                                return $this->load_result(TRUE);  
    249248                        } 
    250249                        else 
    251250                        { 
    252                                 $this->find(NULL, FALSE); 
    253                                 // maintain chainability 
    254                                 return $this; 
     251                                // Allow chains 
     252                                return $this->find(); 
    255253                        } 
    256254                } 
     
    343341 
    344342                                        // Load the related object 
    345                                         $model->find(current($args), FALSE); 
     343                                        $model->find(current($args)); 
    346344                                } 
    347345                        } 
     
    465463         * @return  array    if ALL is used 
    466464         */ 
    467         public function find($id = FALSE, $return = TRUE) 
     465        public function find($id = FALSE, $return = FALSE) 
    468466        { 
    469467                // Allows the use of find(ALL) 
     
    646644        { 
    647645                // Make sure there is something to select 
    648                 ($this->select == FALSE) and self::$db->select($this->table.'.*'); 
     646                $this->select or self::$db->select($this->table.'.*'); 
    649647 
    650648                // Fetch the query result 
    651                 $result = self::$db 
    652                         ->from($this->table) 
    653                         ->get() 
    654                         ->result(TRUE); 
     649                $result = self::$db->get($this->table)->result(TRUE); 
    655650 
    656651                if (count($result) > 0) 
     
    718713        protected function load_model($table) 
    719714        { 
    720                 // Get model name 
    721                 $model= ucfirst(inflector::singular($table)).'_Model'; 
    722  
    723                 // Create a new model 
    724                 return new $model(); 
     715                // Create and return the object 
     716                return ORM::factory(inflector::singular($table)); 
    725717        } 
    726718 
     
    755747        protected function related_join($table) 
    756748        { 
    757                 $join_table = $this->related_table($table); 
     749                $join = $this->related_table($table); 
    758750 
    759751                // Primary and foreign keys 
     
    765757 
    766758                // Execute the join 
    767                 self::$db 
    768                         ->where("$join_table.$primary", $this->object->id) 
    769                         ->join($join_table, "$join_table.$foreign = $table.id"); 
     759                self::$db->where("$join.$primary", $this->object->id)->join($join, "$join.$foreign = $table.id"); 
    770760        } 
    771761