예제 #1
0
 /**
  * @param ActiveRecord $model
  * @param Query $query
  * @return ActiveDataProvider
  */
 public function getDataProvider(ActiveRecord $model, Query $query)
 {
     return new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => array_fill_keys($model->primaryKey(), SORT_ASC)]]);
 }
예제 #2
0
 /**
  * Returns all primary and foreign key column names for specified model.
  * @param ActiveRecord $model
  * @param bool $includePrimary
  * @return array names of columns from primary and foreign keys
  */
 public static function getModelKeys($model, $includePrimary = true)
 {
     $keys = array_map(function ($foreignKey) {
         array_shift($foreignKey);
         return array_keys($foreignKey);
     }, $model->getTableSchema()->foreignKeys);
     if ($includePrimary) {
         $keys[] = $model->primaryKey();
     }
     return call_user_func_array('array_merge', $keys);
 }