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


PHP Collection::ids方法代码示例

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


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

示例1: handler_images

 protected function handler_images(Collection $frankizimages, $size)
 {
     $_frankizimages = array();
     foreach ($frankizimages as $frankizimage) {
         $_frankizimages[$frankizimage->id()] = array();
     }
     $iter = XDB::iterRow("SELECT  iid, size, x, y, data\n                                FROM  images_sizes\n                               WHERE  size IN {?} AND iid IN {?}", $fields, $frankizimages->ids());
     while ($datas = $iter->next()) {
         $_frankizimages[$datas['iid']][$datas['size']] = new Image($datas);
     }
     foreach ($frankizimages as $frankizimage) {
         $frankizimage->fillFromArray(array('images' => $_frankizimages[$frankizimage->id()]));
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:14,代码来源:frankizimage.php

示例2: handler_participants

 protected function handler_participants(Collection $activities, $fields)
 {
     $res = XDB::iterator('SELECT  id, participant
                             FROM  activities_participants
                            WHERE  id IN {?}', $activities->ids());
     $users = new Collection('User');
     $part = array();
     while ($datas = $res->next()) {
         $part[$datas['id']][] = $users->addget($datas['participant']);
     }
     foreach ($part as $key => $obj) {
         $activities->get($key)->participants($obj);
     }
     $users->select($this->subs['participants']);
 }
开发者ID:netixx,项目名称:frankiz,代码行数:15,代码来源:activityinstance.php

示例3: handler_item

 protected function handler_item(Collection $validates, $fields)
 {
     $items = array();
     foreach ($validates as $validate) {
         $items[$validate->id()] = array();
     }
     $iter = XDB::iterRow("SELECT  id, item\n                                FROM  validate\n                               WHERE  id IN {?}", $validates->ids());
     while (list($id, $item) = $iter->next()) {
         $items[$id] = unserialize($item);
     }
     $selects = array();
     $collections = array();
     foreach ($items as $item) {
         foreach ($item->objects() as $field => $select) {
             $hash = $select->hash();
             $selects[$hash] = $select;
             if (empty($collections[$hash])) {
                 $collections[$hash] = new Collection($select->className());
             }
             if ($item->{$field}() != false) {
                 $item->{$field}($collections[$hash]->addget($item->{$field}()));
             }
         }
         foreach ($item->collections() as $field => $select) {
             $hash = $select->hash();
             $selects[$hash] = $select;
             if (empty($collections[$hash])) {
                 $collections[$hash] = new Collection($select->className());
             }
             if ($item->{$field}() != false) {
                 $temp = new Collection($select->className());
                 foreach ($item->{$field}() as $f) {
                     $temp->add($collections[$hash]->addget($f));
                 }
                 $item->{$field}($temp);
             }
         }
     }
     foreach ($collections as $hash => $collection) {
         $collection->select($selects[$hash]);
     }
     foreach ($validates as $validate) {
         $validate->fillFromArray(array('item' => $items[$validate->id()]));
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:45,代码来源:validate.php

示例4: handler_promos

 protected function handler_promos(Collection $formations, $fields)
 {
     $_formations = array();
     foreach ($formations as $f) {
         $_formations[$f->id()] = array();
     }
     $iter = XDB::iterRow('SELECT  formation_id AS id,
                                   GROUP_CONCAT(DISTINCT promo ORDER BY promo SEPARATOR ",") AS p
                             FROM  studies
                            WHERE  formation_id IN {?}
                         GROUP BY  formation_id', $formations->ids());
     while (list($id, $promos) = $iter->next()) {
         $promos = explode(',', $promos);
         foreach ($promos as &$p) {
             $p = (int) $p;
         }
         sort($promos);
         $_formations[$id] = $promos;
     }
     foreach ($formations as $f) {
         $f->fillFromArray(array('promos' => $_formations[$f->id()]));
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:23,代码来源:formation.php

示例5: handler_questions

 protected function handler_questions(Collection $surveys, array $fields)
 {
     $_surveys = array();
     foreach ($surveys as $s) {
         $_surveys[$s->id()] = new Collection('SurveyQuestion');
         $_surveys[$s->id()]->order('rank', false);
     }
     $iter = XDB::iterRow("SELECT  qid, survey, type\n                                FROM  surveys_questions\n                               WHERE  survey IN {?}", $surveys->ids());
     $questions = new Collection('SurveyQuestion');
     while (list($qid, $sid, $type) = $iter->next()) {
         $className = 'SurveyQuestion' . $type;
         $question = new $className($qid);
         $questions->add($question);
         $_surveys[$sid]->add($question);
     }
     foreach ($surveys as $s) {
         $s->fillFromArray(array('questions' => $_surveys[$s->id()]));
     }
     if (!empty($questions) && !empty($this->subs['questions'])) {
         $questions->select($this->subs['questions']);
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:22,代码来源:survey.php

示例6: helper_flagset

 /**
  * Select an FlagSet from the database into a field
  *
  * @param Collection $metas The objects to select
  * @param string $field An FlagSet field
  */
 protected function helper_flagset(Collection $metas, $field)
 {
     $_metas = array();
     foreach ($metas as $meta) {
         $_metas[$meta->id()] = new PlFlagSet();
     }
     // Query database according to the schema
     $id = $this->schema->id();
     list($table, $column) = $this->schema->flagsetType($field);
     $iter = XDB::iterRow("SELECT  {$id}, {$column}\n                                FROM  {$table}\n                               WHERE  {$id} IN {?}", $metas->ids());
     // Put database result in a id => array(l_col) fashion
     while (list($id, $value) = $iter->next()) {
         $_metas[$id]->addFlag($value);
     }
     // Fill metas
     foreach ($metas as $meta) {
         $meta->fillFromArray(array($field => $_metas[$meta->id()]));
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:25,代码来源:select.php

示例7: defaultFilters

 /**
  * Getter & Setter for the groups to be displayed by default in the groups_pickers
  * /!\ When you set a Collection, the groups must have been fetched.
  */
 public function defaultFilters(Collection $groups = null)
 {
     if ($groups !== null) {
         if ($groups === false) {
             XDB::execute('DELETE FROM  users_defaultfilters
                                 WHERE  uid = {?}', $this->id());
         } else {
             $export = json_encode($groups->ids());
             XDB::execute('INSERT INTO  users_defaultfilters
                                   SET  uid = {?}, defaultfilters = {?}
               ON DUPLICATE KEY UPDATE  defaultfilters = {?}', $this->id(), $export, $export);
         }
         $this->defaultfilters = $groups;
     }
     return $this->defaultfilters;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:20,代码来源:user.php

示例8: selectRights

 public function selectRights(Collection $users)
 {
     $rights = array();
     if ($users->count() > 0) {
         $iter = XDB::iterRow('SELECT  cu.uid, c.rights
                                  FROM  castes AS c
                            INNER JOIN  castes_users AS cu ON (cu.cid = c.cid
                                        AND (cu.visibility IN {?} OR cu.uid = {?}))
                            INNER JOIN  groups AS g ON g.gid = c.`group`
                                 WHERE  g.gid = {?} AND cu.uid IN {?}', S::user()->visibleGids(), S::user()->id(), $this->id(), $users->ids());
         while (list($uid, $right) = $iter->next()) {
             if (empty($rights[$uid])) {
                 $rights[$uid] = array();
             }
             $rights[$uid][] = new Rights($right);
         }
     }
     return $rights;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:19,代码来源:group.php

示例9: handler_star

 protected function handler_star(Collection $news, $fields)
 {
     foreach ($news as $n) {
         $n->fillFromArray(array('star' => false));
     }
     $iter = XDB::iterRow("SELECT  uid, news, time\n                                FROM  news_star\n                               WHERE  news IN {?} AND uid = {?}", $news->ids(), S::user()->id());
     while (list($uid, $nid, $time) = $iter->next()) {
         $news->get($nid)->fillFromArray(array('star' => new FrankizDateTime($time)));
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:10,代码来源:news.php

示例10: array

 function handler_group_ajax_users($page)
 {
     $group = Json::i('gid');
     $limit = 25;
     $group = Group::fromId($group);
     $users = false;
     if ($group) {
         $users = array();
         $group->select(GroupSelect::castes());
         $order = new UFO_Name(UFO_Name::LASTNAME);
         $filters = new PFC_True();
         if (strlen(Json::t('promo')) > 0) {
             $filters = new UFC_Group(explode(';', Json::v('promo')));
         }
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::admin())), $filters), $order);
         $admins = $uf->get(new PlLimit($limit, (Json::i('admin_page', 1) - 1) * $limit));
         $admins_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste(array($group->caste(Rights::member()), $group->caste(Rights::logic()))), $filters), $order);
         $members = $uf->get(new PlLimit($limit, (Json::i('member_page', 1) - 1) * $limit));
         $members_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::friend())), $filters), $order);
         $friends = $uf->get(new PlLimit($limit, (Json::i('friend_page', 1) - 1) * $limit));
         $friends_total = $uf->getTotalCount();
         $all = new Collection('User');
         $all->safeMerge(array($admins, $members, $friends));
         $all->select(UserSelect::base());
         $admins_export = $admins->export(User::EXPORT_MICRO, true);
         $members_export = $members->export(User::EXPORT_MICRO, true);
         $friends_export = $friends->export(User::EXPORT_MICRO, true);
         if ($all->count() > 0) {
             $iter = XDB::iterRow('SELECT  uid, comment
                                     FROM  users_comments
                                    WHERE  gid = {?} AND uid IN {?}', $group->id(), $all->ids());
             while (list($uid, $comment) = $iter->next()) {
                 if ($admins_export[$uid]) {
                     $admins_export[$uid]['comments'] = $comment;
                 }
                 if ($members_export[$uid]) {
                     $members_export[$uid]['comments'] = $comment;
                 }
                 if ($friends_export[$uid]) {
                     $friends_export[$uid]['comments'] = $comment;
                 }
             }
         }
         $users['admin'] = array('total' => $admins_total, 'users' => $admins_export);
         $users['member'] = array('total' => $members_total, 'users' => $members_export);
         $users['friend'] = array('total' => $friends_total, 'users' => $friends_export);
     }
     $page->jsonAssign('limit', $limit);
     $page->jsonAssign('users', $users);
     return PL_JSON;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:53,代码来源:groups.php

示例11: batchFrom

 /**
  * Try to retrieve the id and return a collection of the corresponding objects
  *  thanks to another unique identifier passed as argument
  * If the function can't find an object for each identifier passed, it must throw
  *  an ItemNotFoundException
  *
  * @param $mixed  An array containing a unique identifier (often it's a unique name)
  */
 public static function batchFrom(array $mixed)
 {
     // The schema may specify a key
     $schema = Schema::get(get_called_class());
     $className = $schema->className();
     $key = $schema->fromKey();
     if (empty($key)) {
         throw new Exception("batchFrom isn't implemented");
     }
     $collec = new Collection();
     if (!empty($mixed)) {
         $iter = XDB::iterator('SELECT  ' . $schema->id() . ' AS id, ' . $key . '
                                  FROM  ' . $schema->table() . '
                                 WHERE  ' . $key . ' IN {?}', $mixed);
         while ($data = $iter->next()) {
             $collec->add(new $className($data));
         }
         if ($collec->count() == 0) {
             throw new ItemNotFoundException('Nothing found for ' . implode(', ', $mixed));
         }
         if (count($mixed) != $collec->count()) {
             throw new ItemNotFoundException('Asking for ' . implode(', ', $mixed) . ' but only found ' . implode(', ', $collec->ids()));
         }
     }
     return $collec;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:34,代码来源:meta.php

示例12: groups

 public function groups(Collection $groups = null)
 {
     if ($groups != null) {
         $oldGids = $this->groups->ids();
         $newGids = $groups->ids();
         // Remove no longer used groups
         foreach (array_diff($oldGids, $newGids) as $gid) {
             $this->removeGroup($this->groups->get($gid));
         }
         // Add new groups
         foreach (array_diff($newGids, $oldGids) as $gid) {
             $this->addGroup($groups->get($gid));
         }
     }
     return $this->groups;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:16,代码来源:remote.php


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