當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。