Changeset 2312

Show
Ignore:
Timestamp:
03/17/2008 10:01:21 AM (10 months ago)
Author:
Shadowhand
Message:

Follow up to r2311

Files:
1 modified

Legend:

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

    r2311 r2312  
    556556                        return $this->find_all(); 
    557557 
     558                // To allow the object to be reloaded 
     559                ($id === TRUE) and $id = $this->id; 
     560 
    558561                // Generate WHERE 
    559562                if ($this->where === FALSE AND ! empty($id)) 
    560563                { 
    561                         if ($id === TRUE) 
    562                         { 
    563                                 self::$db->where($this->object->id); 
    564                         } 
    565                         elseif (is_array($id)) 
     564                        if (is_array($id)) 
    566565                        { 
    567566                                self::$db->where($id); 
     
    609608                } 
    610609 
    611                 if ($this->object->id == '') 
     610                if (empty($this->object->id)) 
    612611                { 
    613612                        // Perform an insert 
    614613                        $query = self::$db->insert($this->table, $data); 
    615614 
    616                         if ($query->count() === 1) 
     615                        if ($query->count()) 
    617616                        { 
    618617                                // Set current object id by the insert id 
     
    626625                } 
    627626 
    628                 if ($query->count() === 1) 
     627                if ($query->count()) 
    629628                { 
    630629                        // Reset changed data 
    631630                        $this->changed = array(); 
     631 
     632                        // Reset SELECT, WHERE, and FROM 
     633                        $this->select = $this->where = $this->from = FALSE; 
    632634 
    633635                        return TRUE;