当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayHelper::extract方法代码示例

本文整理汇总了PHP中ArrayHelper::extract方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::extract方法的具体用法?PHP ArrayHelper::extract怎么用?PHP ArrayHelper::extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayHelper的用法示例。


在下文中一共展示了ArrayHelper::extract方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderContent

 public function renderContent()
 {
     $user_id = Yii::app()->user->id;
     $sql = "SELECT DISTINCT users.id\n                       FROM users\n                       INNER JOIN messages\n                               ON (messages.to_user_id = {$user_id} OR messages.from_user_id = {$user_id})\n                       ORDER BY messages.date_create";
     $users_ids = Yii::app()->db->createCommand($sql)->queryAll();
     $users_ids = ArrayHelper::extract($users_ids, 'id');
     $this->render('MessageDialogsSidebar', array('users' => User::model()->findAllByPk($users_ids)));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:8,代码来源:MessageDialogsSidebar.php

示例2: getList

 public static function getList()
 {
     $languages = Yii::app()->cache->get('languages');
     if (!$languages) {
         $languages = ArrayHelper::extract(Language::model()->findAll(), 'id', 'name');
         Yii::app()->cache->set('languages', $languages);
     }
     return $languages;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:9,代码来源:Language.php

示例3: init

 public function init()
 {
     $class = 'application.components.activeRecordBehaviors.MetaTagBehavior';
     $behaviors = $this->model->behaviors();
     $classes = ArrayHelper::extract($behaviors, 'class');
     if (!in_array($class, $classes)) {
         throw new CException("Модель должна иметь поведение: {$class}");
     }
     parent::init();
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:10,代码来源:MetaTags.php

示例4: getList

 public static function getList()
 {
     $messages = Yii::app()->cache->get('languages_messages');
     if ($messages === false) {
         $sql = "SELECT message FROM " . self::tableName();
         $res = Yii::app()->db->createCommand($sql)->queryAll();
         $messages = ArrayHelper::extract($res, 'message');
         Yii::app()->cache->set('languages_messages', $messages);
     }
     return $messages;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:11,代码来源:LanguageMessage.php

示例5: getModels

 public static function getModels($params = array())
 {
     $result = array();
     $modules_dirs = scandir(MODULES_PATH);
     foreach ($modules_dirs as $module_dir) {
         if ($module_dir[0] == '.') {
             continue;
         }
         $module_class = ucfirst($module_dir) . 'Module';
         if (array_key_exists('active', $params)) {
             $active_attr = new ReflectionProperty($module_class, 'active');
             if ($active_attr->getValue() !== $params['active']) {
                 continue;
             }
         }
         $models_dir = MODULES_PATH . $module_dir . '/models';
         if (!file_exists($models_dir)) {
             continue;
         }
         $models_files = scandir($models_dir);
         foreach ($models_files as $model_file) {
             if ($model_file[0] == '.') {
                 continue;
             }
             $model_class = str_replace('.php', null, $model_file);
             $model = ActiveRecordModel::model($model_class);
             if (isset($params['meta_tags'])) {
                 $behaviors = $model->behaviors();
                 $behaviors = ArrayHelper::extract($behaviors, 'class');
                 if (!in_array('application.components.activeRecordBehaviors.MetaTagBehavior', $behaviors)) {
                     continue;
                 }
             }
             $result[$model_class] = $model->name();
         }
     }
     return $result;
 }
开发者ID:nizsheanez,项目名称:alp.ru,代码行数:38,代码来源:AppManager.php

示例6: getErrorsStr

 public function getErrorsStr()
 {
     return implode("\n", ArrayHelper::extract($this->getErrorsArray(), 'error'));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:4,代码来源:ActiveRecord.php

示例7: markObjects

 /**
  * @static
  *
  * @param Array $objects объекты или массивы
  * @param String $keyAttribute атрибут который будет выступать в роли ключа
  *
  * @return array
  */
 public static function markObjects($array, $keyAttribute)
 {
     return array_combine(ArrayHelper::extract($array, $keyAttribute), $array);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:12,代码来源:ArrayHelper.php

示例8: array

<?php

if (!$this->model->isNewRecord) {
    $translations = LanguageTranslation::model()->findAll('id = ' . $this->model->id);
    $translations = ArrayHelper::extract($translations, 'language', 'translation');
}
$elements = array('message' => array('type' => 'textarea'));
$languages = Language::getList();
foreach ($languages as $id => $language) {
    if (Yii::app()->language == $id) {
        continue;
    }
    $value = null;
    if (isset($translations) && isset($translations[$id])) {
        $this->model->translations[$id] = $translations[$id];
    }
    $elements["translations[{$id}]"] = array('type' => 'textarea', 'label' => $language, 'value' => $value);
}
return array('activeForm' => array('id' => 'language-translation-form'), 'elements' => $elements, 'buttons' => array('submit' => array('type' => 'submit', 'value' => 'Сохранить')));
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:19,代码来源:LanguageTranslationForm.php

示例9: getOutcomingFriendsIds

 public static function getOutcomingFriendsIds($user_id, $is_confirmed = 0)
 {
     $sql = "SELECT user_b_id\n                       FROM " . self::model()->tableName() . "\n                       WHERE user_a_id = {$user_id} AND\n                       is_confirmed = {$is_confirmed}";
     $friends_ids = Yii::app()->db->createCommand($sql)->queryAll();
     return ArrayHelper::extract($friends_ids, 'user_b_id');
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:6,代码来源:Friend.php


注:本文中的ArrayHelper::extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。