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


PHP Set::combine方法代码示例

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


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

示例1: updateGroups

 /**
  * Updates all the group events
  *
  * @param int   $eventId   Event id
  * @param array $newGroups new goups for the event
  *
  * @access public
  * @return boolean
  */
 function updateGroups($eventId, $newGroups)
 {
     if (null == $newGroups) {
         return false;
     }
     if (!is_array($newGroups)) {
         $newGroups = array($newGroups);
     }
     //get old groupid's
     $tmp = $this->getGroupIDsByEventId($eventId);
     $oldGroups = Set::extract($tmp, '/GroupEvent/group_id');
     $mapping = Set::combine($tmp, '{n}.GroupEvent.group_id', '{n}.GroupEvent.id');
     $insertGroups = array();
     $deleteGroups = array();
     //compare
     $insertGroups = array_diff($newGroups, $oldGroups);
     $deleteGroups = array_diff($oldGroups, $newGroups);
     //insert
     foreach ($insertGroups as $groupId) {
         $tmp = array('event_id' => $eventId, 'group_id' => $groupId, 'marked' => 'not reviewed');
         $this->save($tmp);
         $this->id = null;
     }
     // delete
     foreach ($deleteGroups as $groupId) {
         $this->delete($mapping[$groupId]);
         $this->id = null;
     }
     return true;
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:39,代码来源:group_event.php

示例2: getSubmission

 function getSubmission($formId)
 {
     $submission = $this->findByCformId($formId);
     $submission['SubmissionField'] = Set::combine($submission['SubmissionField'], '{n}.form_field', '{n}.response');
     $submission = Set::merge($submission['Submission'], $submission['SubmissionField']);
     return $submission;
 }
开发者ID:sambernard,项目名称:cakeforms,代码行数:7,代码来源:submission.php

示例3: temmatesOfCompletedOrPendingTeams

 /**
  * Get teammates user_id for the teams for some model, model_id
  * @author Oleg D.
  */
 function temmatesOfCompletedOrPendingTeams($model, $modelID)
 {
     $sql = "SELECT DISTINCT(tm.user_id)\n        FROM teams t\n        INNER JOIN teammates tm ON t.id = tm.team_id\n        INNER JOIN teams_objects tob ON t.id = tob.team_id\n        WHERE tob.model = '" . $model . "' AND tob.model_id = " . $modelID . " AND tob.status = 'created' AND tm.status IN ('Creator', 'Accepted','Pending') AND t.status IN ('Completed','Created','Pending')";
     $results = $this->query($sql);
     $usersIDs = Set::combine($results, '{n}.tm.user_id', '{n}.tm.user_id');
     return $usersIDs;
 }
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:11,代码来源:Teammate.php

示例4: admin_edit

 /**
  * admin_edit method
  *
  * @throws NotFoundException
  * @param string $id
  * @return void
  */
 public function admin_edit($id = null)
 {
     $this->Category->locale = array_keys(Configure::read('Site.languages'));
     if (!$this->Category->exists($id)) {
         throw new NotFoundException(__('Invalid category'));
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         if ($this->Category->saveAssociated($this->request->data)) {
             $this->Session->setFlash(__('The category has been saved'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The category could not be saved. Please, try again.'));
         }
     } else {
         $options = array('conditions' => array('Category.' . $this->Category->primaryKey => $id));
         $this->request->data = $this->Category->find('first', $options);
         foreach ($this->Category->actsAs['Translate'] as $field => $fieldAlias) {
             $translations = Set::combine($this->request->data, $fieldAlias . '.{n}.locale', $fieldAlias . '.{n}.content');
             $this->request->data['Category'][$field] = $translations;
         }
     }
     $parentCategories = $this->Category->find('list', array('conditions' => array('parent_id' => null)));
     $services = $this->Category->Service->find('list');
     $statements = $this->Category->Statement->find('list');
     $this->set(compact('parentCategories', 'services', 'statements'));
 }
开发者ID:priyankasingh,项目名称:Genie,代码行数:33,代码来源:CategoriesController.php

示例5: new_entry

 function new_entry($id = null)
 {
     App::import('Model', 'TblData');
     $this->TblData = new TblData();
     // ブログの設定の読み込み
     App::import('Model', 'MstBlogSetting');
     $this->MstBlogSetting = new MstBlogSetting();
     // ユーザカテゴリの取得
     App::import('Model', 'TblUserCategory');
     $this->TblUserCategory = new TblUserCategory();
     $this->MstBlogSetting->recursive = 3;
     // ブログ設定を読み込む
     $setting = $this->MstBlogSetting->getBlogSettingByAccountName($this->user['account_name']);
     $this->set('setting', $setting);
     $this->set('UserCategory', $this->TblUserCategory->getSelectArray($setting['TblUserCategory']));
     // ジャンルの取得
     App::import('Model', 'MstGenreMajor');
     App::import('Model', 'MstGenreMinor');
     $this->MstGenreMajor = new MstGenreMajor();
     $this->MstGenreMinor = new MstGenreMinor();
     $minorGenre = $this->MstGenreMinor->getGenreList();
     // ジャンルのoptgroupが出きるように配列を整理
     $genre = Set::combine($minorGenre, '{n}.MstGenreMinor.id', '{n}.MstGenreMinor.name', '{n}.MstGenreMajor.name');
     $this->set('genre', $genre);
     $this->render('new_entry');
 }
开发者ID:a2c4595467,项目名称:blog,代码行数:26,代码来源:article_controller.php

示例6: config

 function config()
 {
     $data = $this->find('all');
     $data = Set::combine($data, '{n}.Configurator.key', '{n}.Configurator.value');
     Cache::write('Config', $data);
     return $data;
 }
开发者ID:amerlini,项目名称:digigas-from-hg,代码行数:7,代码来源:configurator.php

示例7: add

 /**
  * add method
  *
  * @return void
  */
 public function add($event_id = null)
 {
     $this->loadModel('StudentInfo');
     $student = $this->StudentInfo->findByUserId($this->Session->read('Auth.User.id'));
     if (empty($student)) {
         $this->Session->setFlash(__('Your account type cannot sign up for events.'), 'default', array('class' => 'alert alert-danger'));
         return $this->redirect($this->referer());
     }
     $event = $this->StudentJob->Event->findById($event_id);
     $jobs = Set::combine($event['Job'], '{n}.id', '{n}.name');
     if ($this->request->is('post')) {
         $job = $this->StudentJob->Job->findById($this->request->data['StudentJob']['job_id']);
         $this->Hour->addHour($this->request->data, $event);
         $this->StudentJob->create();
         $this->request->data['StudentJob']['event_id'] = $event_id;
         $this->request->data['StudentJob']['user_id'] = $this->Session->read('Auth.User.id');
         $this->request->data['StudentJob']['total_hours'] = $job['Job']['end_time'] - $job['Job']['start_time'];
         if ($this->StudentJob->save($this->request->data)) {
             $this->Flash->success(__('The student job has been saved.'));
             $this->StudentJob->Job->recursive = -1;
             $job['Job']['available_positions']--;
             $this->StudentJob->Job->save($job);
             return $this->redirect('/myEvents');
         } else {
             $this->Flash->error(__('The student job could not be saved. Please, try again.'));
         }
     }
     $this->set(compact('event', 'users', 'jobs'));
 }
开发者ID:robertrico,项目名称:CSC131,代码行数:34,代码来源:StudentJobsController.php

示例8: admin_index

 /**
  * admin_index
  *
  * @return void
  */
 public function admin_index()
 {
     $this->set('title_for_layout', __('Permissions'));
     $acoConditions = array('parent_id !=' => null, 'foreign_key' => null, 'alias !=' => null);
     $acos = $this->Acl->Aco->generateTreeList($acoConditions, '{n}.Aco.id', '{n}.Aco.alias');
     $roles = $this->Role->find('list');
     $this->set(compact('acos', 'roles'));
     $rolesAros = $this->AclAro->find('all', array('conditions' => array('AclAro.model' => 'Role', 'AclAro.foreign_key' => array_keys($roles))));
     $rolesAros = Set::combine($rolesAros, '{n}.AclAro.foreign_key', '{n}.AclAro.id');
     $permissions = array();
     // acoId => roleId => bool
     foreach ($acos as $acoId => $acoAlias) {
         if (substr_count($acoAlias, '_') != 0) {
             $permission = array();
             foreach ($roles as $roleId => $roleTitle) {
                 $hasAny = array('aco_id' => $acoId, 'aro_id' => $rolesAros[$roleId], '_create' => 1, '_read' => 1, '_update' => 1, '_delete' => 1);
                 if ($this->AclPermission->hasAny($hasAny)) {
                     $permission[$roleId] = 1;
                 } else {
                     $permission[$roleId] = 0;
                 }
                 $permissions[$acoId] = $permission;
             }
         }
     }
     $this->set(compact('rolesAros', 'permissions'));
 }
开发者ID:romaing,项目名称:croogo-rg,代码行数:32,代码来源:AclPermissionsController.php

示例9: view

 function view($id = null)
 {
     if (!$id) {
         $this->Session->setFlash(sprintf(__('%s non valido', true), 'Forum'));
         $this->redirect(array('action' => 'index'));
     }
     $forum = $this->Forum->find('first', array('conditions' => array('Forum.id' => $id, 'Forum.active' => 1, 'Forum.access_level >= ' => $this->Auth->user('role')), 'contain' => array('User.fullname', 'User.id')));
     if (empty($forum)) {
         $this->Session->setFlash(__('Non puoi accedere a questo forum', true));
         $this->redirect(array('action' => 'index'));
     }
     $this->paginate = array('Comment' => array('conditions' => array('Comment.model' => 'Forum', 'Comment.item_id' => $id, 'Comment.active' => 1, 'Comment.parent_id' => 0), 'fields' => array('Comment.*', "CONCAT(LastUser.first_name, ' ', LastUser.last_name) AS LastUser__fullname", "CONCAT(User.first_name, ' ', User.last_name) AS User__fullname"), 'order' => array('Comment.created DESC'), 'contain' => array('Comment', 'User', 'LastUser', 'LastComment.created'), 'limit' => 25));
     $comments = $this->paginate($this->Forum->Comment);
     foreach ($comments as $key => $comment) {
         $comments[$key]['Comment']['status'] = $this->Forum->getThreadStatus($comment['Comment']['id']);
     }
     $commentIds = Set::extract('/Comment/id', $comments);
     $commentsChildren = $this->Comment->find('all', array('conditions' => array('Comment.model' => 'Forum', 'Comment.parent_id' => $commentIds, 'Comment.active' => 1), 'fields' => array('Comment.parent_id', 'count(id) as children'), 'group' => 'parent_id', 'recursive' => -1));
     $commentsChildren = Set::combine($commentsChildren, '{n}.Comment.parent_id', '{n}.0.children');
     $lastUpdates = $this->Comment->find('all', array('conditions' => array('Comment.model' => 'Forum', 'Comment.parent_id' => $commentIds, 'Comment.active' => 1), 'fields' => array('Comment.parent_id', 'MAX(created) as created'), 'group' => 'parent_id', 'recursive' => -1));
     $lastUpdates = Set::combine($lastUpdates, '{n}.Comment.parent_id', '{n}.0.created');
     $lastMessages = $this->Comment->find('all', array('conditions' => array('Comment.model' => 'Forum', 'Comment.item_id' => $id, 'Comment.active' => 1), 'order' => array('Comment.created DESC'), 'limit' => 10, 'contain' => array('User.fullname')));
     $this->set(compact('forum', 'comments', 'commentsChildren', 'lastUpdates', 'lastMessages'));
     $this->set('title_for_layout', 'Forum - ' . $forum['Forum']['name']);
 }
开发者ID:amerlini,项目名称:digigas-from-hg,代码行数:25,代码来源:forums_controller.php

示例10: edit

 function edit($id)
 {
     //		if( (isset($this->data['Service']['submit'])) || (empty($this->data)) ) {
     if (empty($this->data)) {
         if (!$id) {
             $this->Session->setFlash('Invalid Service');
             $this->redirect($this->referer('/'));
         }
         $this->data = $this->Service->findById($id);
         //$this->set('service',$this->data);
         $this->pageTitle = "Edit Service: {$this->data['Service']['title']}";
         $this->set('user', Set::combine($this->Service->User->find('all', array('recursive' => 0)), '{n}.User.id', '{n}.User.name'));
         $this->set('customers', Set::combine($this->Service->Customer->find('all', array('recursive' => 0)), '{n}.Customer.id', '{n}.Customer.company_name'));
     } else {
         //$this->set('service',$this->Service->find(array('Service.id'=>$id)));
         if ($this->Service->save($this->data)) {
             $this->Session->setFlash("Website saved successfully.");
             $this->redirect($this->referer("/customers/view/{$this->data['Service']['customer_id']}"));
         } else {
             $this->Session->setFlash('Please correct errors below.');
             $this->set('user', Set::combine($this->Service->User->find('all', array('recursive' => 0)), '{n}.User.id', '{n}.User.name'));
             $this->set('customers', Set::combine($this->Service->Customer->find('all', array('recursive' => 0)), '{n}.Customer.id', '{n}.Customer.company_name'));
             $this->pageTitle = 'Edit Service: ' . $this->data['Service']['title'];
         }
     }
 }
开发者ID:searchfirst,项目名称:ODN,代码行数:26,代码来源:services_controller.php

示例11: admin_search

 function admin_search($pattern = null)
 {
     $user = parent::getUser();
     # code after form submit
     if (!empty($this->data)) {
         $pattern = "'%" . $this->data['Rule']['pattern'] . "%'";
         $WILDCARD = "'*'";
         $search_result = $this->Rule->query('SELECT * 
                                          FROM rules LEFT JOIN groups on rules.group_id = groups.id 
                                                     LEFT JOIN locations as loc1 on rules.location_id = loc1.id 
                                                     LEFT JOIN locations as loc2 on groups.location_id = loc2.id
                                          WHERE (rules.sitename LIKE ' . $pattern . ' OR rules.sitename = ' . $WILDCARD . ')
                                          AND (rules.location_id = 1 OR rules.location_id = ' . $this->data['Rule']['locations'] . ')
                                          ORDER BY sitename, priority;', $cachequeries = false);
         #pr($search_result);
         $this->set('results', $search_result);
     }
     if (in_array($user['Role']['name'], $this->priv_roles)) {
         $allowed_locations = parent::getAdminLocationIds();
         $find_condition = array('fields' => array('Location.*'), 'conditions' => array("AND" => array('Location.id' => $allowed_locations, 'Location.id NOT' => "1")), 'order' => 'Location.code');
     } else {
         $find_condition = array('fields' => array('Location.*'), 'order' => 'Location.code', 'conditions' => array("id NOT" => "1"));
     }
     $locations_list = $this->Location->find('all', $find_condition);
     $locations = Set::combine($locations_list, '{n}.Location.id', array('%s %s', '{n}.Location.code', '{n}.Location.name'));
     $this->set(compact('locations'));
 }
开发者ID:vovchik09,项目名称:proximus-admin,代码行数:27,代码来源:rules_controller.php

示例12: find

 function find($type, $options = array())
 {
     switch ($type) {
         case 'concatList':
             if (!isset($options['fields']) || count($options['fields']) < 2) {
                 return parent::find('list', $options);
             }
             if (!isset($options['separator'])) {
                 $options['separator'] = ' - ';
             }
             $options['recursive'] = -1;
             $list = parent::find('all', $options);
             for ($i = 1; $i <= 2; $i++) {
                 $field[$i] = str_replace($this->alias . '.', '', $options['fields'][$i]);
             }
             /*
             return Set::combine($list, '{n}.'.$this->alias.'.'.$this->primaryKey,
                 array('%s'.$options['separator'].'%s',
                     '{n}.'.$this->alias.'.'.$field[1],
                     '{n}.'.$this->alias.'.'.$field[2]));
             */
             return Set::combine($list, '{n}.' . $this->alias . '.' . $this->{$field}[1], array('%s' . $options['separator'] . '%s', '{n}.' . $this->alias . '.' . $field[1], '{n}.' . $this->alias . '.' . $field[2]));
             break;
         default:
             return parent::find($type, $options);
             break;
     }
 }
开发者ID:rajankz,项目名称:webspace,代码行数:28,代码来源:AppModel.php

示例13: admin_index

 /**
  * admin_index
  * 
  * @return void
  */
 public function admin_index()
 {
     $acoConditions = array('parent_id !=' => null, 'foreign_key' => null, 'alias !=' => null);
     $acos = $this->Acl->Aco->generateTreeList($acoConditions, '{n}.Aco.id', '{n}.Aco.alias');
     $groups = $this->Group->find('list');
     $this->set(compact('acos', 'groups'));
     $groupsAros = $this->AclAro->find('all', array('conditions' => array('AclAro.model' => 'Group', 'AclAro.foreign_key' => array_keys($groups))));
     $groupsAros = Set::combine($groupsAros, '{n}.AclAro.foreign_key', '{n}.AclAro.id');
     $permissions = array();
     foreach ($acos as $acoId => $acoAlias) {
         if (substr_count($acoAlias, '_') != 0) {
             $permission = array();
             foreach ($groups as $groupId => $groupTitle) {
                 $hasAny = array('aco_id' => $acoId, 'aro_id' => $groupsAros[$groupId], '_create' => 1, '_read' => 1, '_update' => 1, '_delete' => 1);
                 if ($this->AclPermission->hasAny($hasAny)) {
                     $permission[$groupId] = 1;
                 } else {
                     $permission[$groupId] = 0;
                 }
                 $permissions[$acoId] = $permission;
             }
         }
     }
     $this->set(compact('groupsAros', 'permissions'));
     $plugins = CakePlugin::loaded();
     $controllers_plugins = array();
     if (!empty($plugins)) {
         foreach ($plugins as $plugin) {
             $controllers_plugins[] = $this->AclUtility->getControllerList($plugin);
         }
     }
     $controllers = array_merge($this->AclUtility->getControllerList(), $this->AclUtility->getControllerList($plugin));
     $this->set(compact('controllers'));
 }
开发者ID:vinacode,项目名称:CakePHP-ShoppingCart-with-Admin-Managements,代码行数:39,代码来源:PermissionsController.php

示例14: getBilanServiceWithSqlQuery

 function getBilanServiceWithSqlQuery($id = 'all')
 {
     //  Méthode 3 : à l'aide d'une requête SQL directe
     $prefix = $this->tablePrefix;
     if ($id == 'all' or $id == null) {
         $sql = "SELECT perso_id AS id, perso_id, SUM( h_cours ) AS h_cours, SUM( h_td ) AS h_td, SUM( h_tp ) AS h_tp FROM {$prefix}matieres_persos AS MatieresPerso GROUP BY perso_id";
         $result = $this->query($sql);
         $result = Set::combine($result, '{n}.MatieresPerso.id', '{n}.0');
         // Mise en forme l'array pour avoir perso_id comme clé
         return $result;
     } else {
         App::import('Sanitize');
         $id = Sanitize::paranoid($id);
         // use Sanitize for $id to avoid SQL injection
         $sql = "SELECT perso_id AS id, perso_id, SUM( h_cours ) AS h_cours, SUM( h_td ) AS h_td, SUM( h_tp ) AS h_tp FROM {$prefix}matieres_persos AS MatieresPerso WHERE perso_id={$id} GROUP BY perso_id LIMIT 1";
         $result = $this->query($sql);
         if (!empty($result[0])) {
             //$result = Set::merge($result[0]["MatieresPerso"], $result[0][0]);
             //return $result;
             return $result[0][0];
         } else {
             return array('h_cours' => 0, 'h_td' => 0, 'h_tp' => 0);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:25,代码来源:perso.php

示例15: generatetreegrouped

 function generatetreegrouped(&$Model, $conditions = null, $keyPath = null, $valuePath = null, $groupPath = null, $recursive = null)
 {
     $overrideRecursive = $recursive;
     extract($this->settings[$Model->alias]);
     if (!is_null($overrideRecursive)) {
         $recursive = $overrideRecursive;
     }
     if ($keyPath == null && $valuePath == null && $groupPath == null && $Model->hasField($Model->displayField)) {
         $fields = array($Model->primaryKey, $Model->displayField, 'parent_id', $left, $right);
     } else {
         $fields = null;
     }
     if ($keyPath == null) {
         $keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey;
     }
     if ($valuePath == null) {
         $valuePath = '{n}.' . $Model->alias . '.' . $Model->displayField;
     }
     if ($groupPath == null) {
         $groupPath = '{n}.' . $Model->alias . '.parent_id';
     }
     $order = $Model->alias . '.' . $left . ' asc';
     $results = $Model->find('all', compact('conditions', 'fields', 'order', 'recursive'));
     $stack = array();
     foreach ($results as $i => $result) {
         while ($stack && $stack[count($stack) - 1] < $result[$Model->alias][$right]) {
             array_pop($stack);
         }
         $stack[] = $result[$Model->alias][$right];
     }
     if (empty($results)) {
         return array();
     }
     return Set::combine($results, $keyPath, $valuePath, $groupPath);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:35,代码来源:GroupTreeBehavior.php


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