Changeset 1665
- Timestamp:
- 01/02/2008 05:16:56 PM (12 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/ORM.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/ORM.php
r1662 r1665 106 106 { 107 107 // Query and load object 108 $this->find($id , FALSE);108 $this->find($id); 109 109 } 110 110 } … … 242 242 } 243 243 244 // Find requested objects 245 if (isset($all)) 246 { 247 // return array of results 244 if (isset($all)) 245 { 246 // Array of results 248 247 return $this->load_result(TRUE); 249 248 } 250 249 else 251 250 { 252 $this->find(NULL, FALSE); 253 // maintain chainability 254 return $this; 251 // Allow chains 252 return $this->find(); 255 253 } 256 254 } … … 343 341 344 342 // Load the related object 345 $model->find(current($args) , FALSE);343 $model->find(current($args)); 346 344 } 347 345 } … … 465 463 * @return array if ALL is used 466 464 */ 467 public function find($id = FALSE, $return = TRUE)465 public function find($id = FALSE, $return = FALSE) 468 466 { 469 467 // Allows the use of find(ALL) … … 646 644 { 647 645 // Make sure there is something to select 648 ($this->select == FALSE) andself::$db->select($this->table.'.*');646 $this->select or self::$db->select($this->table.'.*'); 649 647 650 648 // 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); 655 650 656 651 if (count($result) > 0) … … 718 713 protected function load_model($table) 719 714 { 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)); 725 717 } 726 718 … … 755 747 protected function related_join($table) 756 748 { 757 $join _table= $this->related_table($table);749 $join = $this->related_table($table); 758 750 759 751 // Primary and foreign keys … … 765 757 766 758 // 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"); 770 760 } 771 761
