Changeset 1596

Show
Ignore:
Timestamp:
12/20/2007 04:34:46 PM (10 months ago)
Author:
Shadowhand
Message:

Changed ORM::find($id) to ORM::find($id, $return = TRUE) and fixed internal calls to match new syntax.

Files:
1 modified

Legend:

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

    r1589 r1596  
    106106                        { 
    107107                                // Query and load object 
    108                                 $this->find($id); 
     108                                $this->find($id, FALSE); 
    109109                        } 
    110110                } 
     
    449449         * Find and load data for the current object. 
    450450         * 
    451          * @param   string  id of the object to find, or ALL 
    452          * @return  object  current object 
    453          * @return  array   if ALL is used 
    454          */ 
    455         public function find($id = FALSE) 
     451         * @param   string   id of the object to find, or ALL 
     452         * @param   boolean  return the result, or load it into the current object 
     453         * @return  object   object instance 
     454         * @return  array    if ALL is used 
     455         */ 
     456        public function find($id = FALSE, $return = TRUE) 
    456457        { 
    457458                // Allows the use of find(ALL) 
     
    466467 
    467468                // Load the result of the query 
    468                 return $this->load_result(FALSE); 
     469                return $this->load_result(FALSE, $return); 
    469470        } 
    470471 
     
    477478        { 
    478479                // Return an array of objects 
    479                 return $this->load_result(TRUE); 
     480                return $this->load_result(TRUE, TRUE); 
    480481        } 
    481482 
     
    631632         *  array   - Multiple row result set 
    632633         */ 
    633         protected function load_result($array = FALSE) 
     634        protected function load_result($array = FALSE, $return = FALSE) 
    634635        { 
    635636                // Make sure there is something to select 
     
    663664                        else 
    664665                        { 
    665                                 // Fetch the first result 
     666                                if ($return === TRUE) 
     667                                { 
     668                                        // Return the first result 
     669                                        return ORM::instance($this->class, $result->current()); 
     670                                } 
     671 
     672                                // Load the first result 
    666673                                $this->object = $result->current(); 
    667674                        }