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


PHP Pool::where方法代码示例

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


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

示例1: pool_list

 public function pool_list(Post $post)
 {
     $html = "";
     $pools = Pool::where("pools_posts.post_id = {$post->id}")->joins("JOIN pools_posts ON pools_posts.pool_id = pools.id")->order("pools.name")->select("pools.name, pools.id")->take();
     if ($pools->blank()) {
         $html .= "none";
     } else {
         $html .= join(", ", array_map(function ($p) {
             return $this->linkTo($this->h($p->pretty_name()), ["pool#show", 'id' => $p->id]);
         }, $pools->members()));
     }
     return $html;
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:13,代码来源:PoolHelper.php

示例2: select

 public function select()
 {
     if (current_user()->is_anonymous()) {
         $this->pools = Pool::where("is_active = TRUE AND is_public = TRUE")->order("name")->take();
     } else {
         $this->pools = Pool::where("is_active = TRUE AND (is_public = TRUE OR user_id = ?)", current_user()->id)->order("name")->take();
     }
     $options = array('(000) DO NOT ADD' => 0);
     foreach ($this->pools as $p) {
         $options[str_replace('_', ' ', $p->name)] = $p->id;
     }
     $this->options = $options;
     $this->last_pool_id = $this->session()->last_pool_id;
     $this->setLayout(false);
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:15,代码来源:PoolController.php

示例3: import

 public function import()
 {
     $import_dir = Rails::publicPath() . '/data/import/';
     if ($this->request()->isPost()) {
         if ($this->request()->format() == 'json') {
             foreach (explode('::', $this->params()->dupes) as $file) {
                 $file = stripslashes(utf8_decode($file));
                 $file = $import_dir . $file;
                 if (file_exists($file)) {
                     unlink($file);
                 } else {
                     $error = true;
                 }
             }
             $resp = !empty($error) ? array('reason' => 'Some files could not be deleted') : array('success' => true);
             $this->render(array('json' => $resp));
             return;
         }
         $this->setLayout(false);
         $this->errors = $this->dupe = false;
         $post = $this->params()->post;
         $post['filename'] = stripslashes(utf8_decode($post['filename']));
         $filepath = $import_dir . $post['filename'];
         # Take folders as tags
         if (is_int(strpos($post['filename'], '/'))) {
             $folders = str_replace('#', ':', $post['filename']);
             $tags = array_filter(array_unique(array_merge(explode(' ', $post['tags']), explode('/', $folders))));
             array_pop($tags);
             $post['tags'] = trim($post['tags'] . ' ' . implode(' ', $tags));
         }
         $post = array_merge($post, array('ip_addr' => $this->request()->remoteIp(), 'user_id' => current_user()->id, 'status' => 'active', 'tempfile_path' => $filepath, 'tempfile_name' => $post['filename'], 'is_import' => true));
         unset($post['filename'], $post['i']);
         $this->post = Post::create($post);
         if ($this->post->errors()->blank()) {
             $this->import_status = 'Posted';
         } elseif ($this->post->errors()->invalid('md5')) {
             $this->dupe = true;
             $this->import_status = 'Already exists';
             $this->post = Post::where(['md5' => $this->post->md5])->first();
             $this->post->status = 'flagged';
         } else {
             $this->errors = $this->post->errors()->fullMessages('<br />');
             $this->import_status = 'Error';
         }
     } else {
         $this->set_title('Import');
         $this->invalid_files = $this->files = [];
         list($this->files, $this->invalid_files, $this->invalid_folders) = Post::get_import_files($import_dir);
         $pools = Pool::where('is_active')->take();
         if ($pools) {
             $this->pool_list = '<datalist id="pool_list">';
             foreach ($pools as $pool) {
                 $this->pool_list .= '<option value="' . str_replace('_', ' ', $pool->name) . '" />';
             }
             $this->pool_list .= '</datalist>';
         } else {
             $this->pool_list = null;
         }
     }
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:60,代码来源:PostController.php

示例4: commit_tags

 /**
  * It's strange how actions like changing pool's sequence, that updates the post via
  * update_batch and sends only one metatag: 'pool:$id:$seq' and doesn't send old_tags, don't
  * mess up the rest of the tags (because that metatag is discarted, and the post is left without
  * old_tags or any tag).
  * So we're gonna do a workaround for that: if the new tags only contain metatags, we won't
  * take any further action but commit such metatags.
  * We'll use $had_metatags for that.
  */
 protected function commit_tags()
 {
     if ($this->isNewRecord() || !$this->new_tags) {
         return;
     }
     if ($this->old_tags) {
         # If someone else committed changes to this post before we did,
         # then try to merge the tag changes together.
         $current_tags = explode(' ', $this->cached_tags);
         $this->old_tags = Tag::scan_tags($this->old_tags);
         $this->new_tags = array_filter(array_merge(array_diff(array_merge($current_tags, $this->new_tags), $this->old_tags), array_intersect($current_tags, $this->new_tags)));
     }
     $this->commit_metatags();
     $meta_tags = ['-pool:', 'pool:', 'rating:', 'parent:', 'child:', 'source:'];
     $ratings = ['q', 's', 'e'];
     $had_metatags = false;
     foreach ($this->new_tags as $k => $tag) {
         # To avoid preg_match.
         $is_mt = false;
         foreach ($meta_tags as $mt) {
             if (strpos($tag, $mt) === 0 || in_array($tag, $ratings)) {
                 $is_mt = true;
                 break;
             }
         }
         if (!$is_mt) {
             continue;
         }
         $had_metatags = true;
         unset($this->new_tags[$k]);
         if (in_array($tag, $ratings)) {
             $tag = 'rating:' . $tag;
         }
         $subparam = explode(':', $tag, 3);
         $metatag = array_shift($subparam);
         $param = array_shift($subparam);
         $subparam = empty($subparam) ? null : array_shift($subparam);
         switch ($metatag) {
             case 'rating':
                 # Change rating. This will override rating selected on radio buttons.
                 if (in_array($param, $ratings)) {
                     $this->rating = $param;
                 }
                 break;
             case 'pool':
                 try {
                     $name = $param;
                     $seq = $subparam;
                     # Workaround: I don't understand how can the pool be found when finding_by_name
                     # using the id.
                     if (ctype_digit($name)) {
                         $pool = Pool::where(['id' => $name])->first();
                     } else {
                         $pool = Pool::where(['name' => $name])->first();
                     }
                     # Set :ignore_already_exists, so pool:1:2 can be used to change the sequence number
                     # of a post that already exists in the pool.
                     $options = array('user' => User::where('id = ?', $this->updater_user_id)->first(), 'ignore_already_exists' => true);
                     if ($seq) {
                         $options['sequence'] = $seq;
                     }
                     if (!$pool and !ctype_digit($name)) {
                         $pool = Pool::create(array('name' => $name, 'is_public' => false, 'user_id' => $this->updater_user_id));
                     }
                     if (!$pool || !$pool->can_change(current_user(), null)) {
                         continue;
                     }
                     $pool->add_post($this->id, $options);
                 } catch (Pool_PostAlreadyExistsError $e) {
                 } catch (Pool_AccessDeniedError $e) {
                 }
                 break;
             case '-pool':
                 $name = $param;
                 $cmd = $subparam;
                 $pool = Pool::where(['name' => $name])->first();
                 if (!$pool->can_change(current_user(), null)) {
                     break;
                 }
                 if ($cmd == "parent") {
                     # If we have a parent, remove ourself from the pool and add our parent in
                     # our place.    If we have no parent, do nothing and leave us in the pool.
                     if (!empty($this->parent_id)) {
                         $pool->transfer_post_to_parent($this->id, $this->parent_id);
                         break;
                     }
                 }
                 $pool && $pool->remove_post($id);
                 break;
             case 'source':
                 $this->source = $param;
//.........这里部分代码省略.........
开发者ID:JCQS04,项目名称:myimouto,代码行数:101,代码来源:TagMethods.php


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