本文整理汇总了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)));
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例6: getErrorsStr
public function getErrorsStr()
{
return implode("\n", ArrayHelper::extract($this->getErrorsArray(), 'error'));
}
示例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);
}
示例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' => 'Сохранить')));
示例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');
}