Changeset 2359

Show
Ignore:
Timestamp:
03/27/2008 12:12:05 PM (8 months ago)
Author:
Shadowhand
Message:

Added ORM::select_list()

Files:
1 modified

Legend:

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

    r2345 r2359  
    591591 
    592592        /** 
     593         * Creates a key/value array from all of the objects available. Uses find_all 
     594         * to find the objects. 
     595         * 
     596         * @param   string  key column 
     597         * @param   string  value column 
     598         * @return  array 
     599         */ 
     600        public function select_list($key_col, $val_col) 
     601        { 
     602                // Select the key an val from all objects 
     603                $array = $this->select($key_col, $val_col)->find_all()->as_array(); 
     604 
     605                $options = array(); 
     606                foreach ($array as $row) 
     607                { 
     608                        // Create a key/value pair array 
     609                        $options[$row->$key_col] = $row->$val_col; 
     610                } 
     611                return $options; 
     612        } 
     613 
     614        /** 
    593615         * Saves the current object. 
    594616         *