Changeset 1437

Show
Ignore:
Timestamp:
12/06/07 20:15:37 (9 months ago)
Author:
Shadowhand
Message:

Changes to core:

  • date::timestamp() variable name typo
  • form::input() no longer puts an id on array-keyed inputs
  • form::label() no longer
  • added arr::unshift_assoc()
  • replace a couple of internal find_all() calls with load_result(TRUE) to avoid an extra method call
  • fixed a bug in Mysql_Result::result_array() that made multiple calls fail after the first call do to the pointer not being reset
  • small code and comment cleanups
Location:
trunk/system
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/arr.php

    r1333 r1437  
    2424         *  The transformed array 
    2525         */ 
    26         function rotate($source_array, $keep_keys = TRUE) 
     26        public function rotate($source_array, $keep_keys = TRUE) 
    2727        { 
    2828                $new_array = array(); 
     
    5050         *  The value of the requested array key 
    5151         */ 
    52         function remove($key, & $array) 
     52        public function remove($key, & $array) 
    5353        { 
    5454                if ( ! isset($array[$key])) 
     
    6060                return $val; 
    6161        } 
    62 } 
     62 
     63        /** 
     64         * Because PHP does not have this function. 
     65         * 
     66         * @param   array   array to unshift 
     67         * @param   string  key to unshift 
     68         * @param   mixed   value to unshift 
     69         * @return  array 
     70         */ 
     71        public function unshift_assoc( array & $array, $key, $val) 
     72        { 
     73                $array = array_reverse($array, TRUE); 
     74                $array[$key] = $val; 
     75                $array = array_reverse($array, TRUE); 
     76 
     77                return $array; 
     78        } 
     79 
     80} // End arr 
  • trunk/system/helpers/date.php

    r1333 r1437  
    298298        { 
    299299                // Default values 
    300                 $time1  = max(0, (int) $time); 
     300                $time1  = max(0, (int) $time1); 
    301301                $time2  = ($time2 === FALSE) ? time() : max(0, (int) $time2); 
    302302 
  • trunk/system/helpers/form.php

    r1333 r1437  
    141141 
    142142                // Form elements should have the same id as name 
    143                 if ( ! isset($data['id'])) 
     143                if ( ! isset($data['id']) AND strpos($data['name'], '[') === FALSE) 
    144144                { 
    145145                        $data['id'] = $data['name']; 
     
    444444                        } 
    445445 
    446                         $data = array 
    447                         ( 
    448                                 'for' => $data 
    449                         ); 
     446                        $data = empty($data) ? array() : array('for' => $data); 
    450447                } 
    451448 
  • trunk/system/libraries/ORM.php

    r1419 r1437  
    229229 
    230230                        // Find requested objects 
    231                         return isset($all) ? $this->find_all() : $this->find(); 
     231                        return isset($all) ? $this->load_result(TRUE) : $this->find(); 
    232232                } 
    233233 
     
    259259                        } 
    260260 
    261                         return $model->find_all(); 
     261                        return $model->load_result(TRUE); 
    262262                } 
    263263 
     
    619619                                $class = get_class($this); 
    620620 
     621                                $result = $result->result_array(); 
     622 
    621623                                $array = array(); 
    622                                 foreach($result->result_array() as $row) 
     624                                foreach($result as $row) 
    623625                                { 
    624626                                        // Add object to the array 
  • trunk/system/libraries/drivers/Database_Mysql.php

    r1389 r1437  
    393393                } 
    394394 
    395                 while ($row = $fetch($this->result, $type)) 
    396                 { 
    397                         $rows[] = $row; 
    398                 } 
    399  
    400                 return $rows; 
     395                if (mysql_num_rows($this->result)) 
     396                { 
     397                        // Reset the pointer location to make sure things work properly 
     398                        mysql_data_seek($this->result, 0); 
     399 
     400                        while ($row = $fetch($this->result, $type)) 
     401                        { 
     402                                $rows[] = $row; 
     403                        } 
     404                } 
     405 
     406                return isset($rows) ? $rows : array(); 
    401407        } 
    402408 
     
    476482        { 
    477483                // Check to see if the requested offset exists. 
    478                 if (!$this->offsetExists($offset)) 
     484                if ( ! $this->offsetExists($offset)) 
    479485                        return FALSE; 
    480486