Changeset 2300

Show
Ignore:
Timestamp:
03/13/2008 02:05:10 AM (10 months ago)
Author:
Shadowhand
Message:

Using $query->count() instead of count($query) for a bit more optimization.

Files:
1 modified

Legend:

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

    r2299 r2300  
    498498                                { 
    499499                                        // Find the many<>many relationship 
    500                                         return (bool) count 
    501                                         ( 
    502                                                 self::$db 
     500                                        return (bool) self::$db 
    503501                                                ->select($primary) 
    504502                                                ->from($this->related_table($table)) 
    505503                                                ->where($relationship) 
    506504                                                ->limit(1) 
    507                                                 ->get() 
    508                                         ); 
     505                                                ->get()->count(); 
    509506                                } 
    510507 
     
    515512                                { 
    516513                                        // Attempt to delete the many<>many relationship 
    517                                         return (bool) count(self::$db->delete($this->related_table($table), $relationship)); 
     514                                        return (bool) self::$db->delete($this->related_table($table), $relationship)->count(); 
    518515                                } 
    519516                                elseif ($model->$primary === $this->object->id) 
     
    613610                        $query = self::$db->insert($this->table, $data); 
    614611 
    615                         if (count($query) === 1) 
     612                        if ($query->count() === 1) 
    616613                        { 
    617614                                // Set current object id by the insert id 
     
    625622                } 
    626623 
    627                 if (count($query) === 1) 
     624                if ($query->count() === 1) 
    628625                { 
    629626                        // Reset changed data 
     
    676673 
    677674                // Return the number of rows deleted 
    678                 return count(self::$db->delete($this->table, $where)); 
     675                return self::$db->delete($this->table, $where)->count(); 
    679676        } 
    680677