Changeset 2026
- Timestamp:
- 02/10/08 12:46:49 (7 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/ORM.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/ORM.php
r2005 r2026 661 661 $result = self::$db->get($this->table)->result(TRUE); 662 662 663 if ($count = $result->count()) 664 { 665 if ($count > 1 OR $array == TRUE) 666 { 667 // Model class name 668 $class = get_class($this); 669 670 return new ORM_Iterator($class, $result); 663 if ($array === TRUE) 664 { 665 // Create a new ORM iterator of the result 666 return new ORM_Iterator(get_class($this), $result); 667 } 668 else 669 { 670 if ($return === TRUE) 671 { 672 // Return the first result 673 return ORM::factory($this->class, $result->current()); 674 } 675 676 // Load the first result, if there is only one result 677 if ($result->count() === 1) 678 { 679 $this->object = $result->current(); 671 680 } 672 681 else 673 682 { 674 if ($return === TRUE) 675 { 676 // Return the first result 677 return ORM::factory($this->class, $result->current()); 678 } 679 680 // Load the first result 681 $this->object = $result->current(); 682 } 683 } 684 else 685 { 686 if ($array == TRUE) 687 { 688 // Return an empty array when an array is requested 689 return array(); 690 } 691 692 // Reset the object 693 $this->clear(); 683 $this->clear(); 684 } 694 685 } 695 686
