Ejemplo n.º 1
0
 /**
  * This function returns an instance of the specified model.
  *
  * @access public
  * @static
  * @param string $model                         the model's name
  * @param array $primary_key                    the column values of the primary key
  *                                              that will be used to load the model
  * @return mixed                                an instance of the specified model
  */
 public static function model($model, $primary_key = array())
 {
     $model = DB_ORM_Model::factory($model);
     if (!empty($primary_key)) {
         if (!is_array($primary_key)) {
             $primary_key = array($primary_key);
         }
         $model_key = $model::primary_key();
         $count = count($model_key);
         for ($i = 0; $i < $count; $i++) {
             $column = $model_key[$i];
             $model->{$column} = $primary_key[$i];
         }
         $model->load();
     }
     return $model;
 }