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


PHP Slug::where方法代码示例

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


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

示例1: Album

 function _slug($field)
 {
     if ($this->edit_slug()) {
         return true;
     }
     if (!empty($this->slug) && $this->slug !== '__generate__') {
         return true;
     }
     $this->load->helper(array('url', 'text', 'string'));
     $slug = reduce_multiples(strtolower(url_title(convert_accented_characters($this->title), 'dash')), '-', true);
     if (empty($slug)) {
         $t = new Album();
         $max = $t->select_max('id')->get();
         $slug = $max->id + 1;
     }
     if (is_numeric($slug)) {
         $slug = "{$slug}-1";
     }
     $s = new Slug();
     while ($s->where('id', "album.{$slug}")->count() > 0) {
         $slug = increment_string($slug, '-');
     }
     $this->db->query("INSERT INTO {$s->table}(id) VALUES ('album.{$slug}')");
     $this->slug = $slug;
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:25,代码来源:album.php

示例2: pathinfo

 function _slug($field)
 {
     if ($this->edit_slug()) {
         return true;
     }
     if (!empty($this->old_slug)) {
         return true;
     }
     $this->load->helper(array('url', 'text', 'string'));
     if (empty($this->title)) {
         $info = pathinfo($this->filename);
         $base = $info['filename'];
     } else {
         $base = $this->title;
     }
     $slug = reduce_multiples(strtolower(url_title(convert_accented_characters($base), 'dash')), '-', true);
     if ($slug === $this->slug) {
         return true;
     }
     if (empty($slug)) {
         $t = new Content();
         $max = $t->select_max('id')->get();
         $slug = $max->id + 1;
     }
     if (is_numeric($slug)) {
         $slug = "{$slug}-1";
     }
     $s = new Slug();
     // Need to lock the table here to ensure that requests arriving at the same time
     // still get unique slugs
     if ($this->has_db_permission('lock tables')) {
         $this->db->query("LOCK TABLE {$s->table} WRITE");
         $locked = true;
     } else {
         $locked = false;
     }
     while ($s->where('id', "content.{$slug}")->count() > 0) {
         $slug = increment_string($slug, '-');
     }
     $this->db->query("INSERT INTO {$s->table}(id) VALUES ('content.{$slug}')");
     if ($locked) {
         $this->db->query('UNLOCK TABLES');
     }
     if (empty($this->old_slug)) {
         if (!empty($this->slug) && $this->slug !== '__generate__') {
             $this->old_slug = ',' . $this->slug . ',';
         } else {
             if (!empty($this->title)) {
                 $this->old_slug = ',' . $slug . ',';
             }
         }
     }
     $this->slug = $slug;
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:54,代码来源:content.php

示例3: strtolower

 function edit_slug()
 {
     if (isset($this->current_slug)) {
         if ($this->current_slug === $this->slug) {
             return;
         }
         $base = strtolower(get_class($this));
         if ($base === 'text') {
             $base = $this->page_type < 1 ? 'essay' : 'page';
         }
         if (preg_match('/[^a-z0-9\\-]/', $this->slug)) {
             throw new Exception('URL slugs can only contain letters, numbers and hyphens.');
         }
         $s = new Slug();
         if ($s->where('id', "{$base}.{$this->slug}")->count() > 0) {
             throw new Exception('This URL slug is already in use. Please enter a different value.');
         } else {
             $old_slugs = explode(',', trim($this->old_slug, ','));
             array_unshift($old_slugs, $this->current_slug);
             $this->old_slug = ',' . implode(',', $old_slugs) . ',';
             $this->db->query("DELETE FROM {$s->table} WHERE id = '{$base}.{$this->current_slug}'");
             $this->db->query("INSERT INTO {$s->table}(id) VALUES ('{$base}.{$this->slug}')");
             return true;
         }
     }
     return false;
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:27,代码来源:koken.php

示例4: Text

 function _slug($field)
 {
     if ($this->edit_slug()) {
         return true;
     }
     $this->load->helper(array('url', 'text', 'string'));
     $slug = reduce_multiples(strtolower(url_title(convert_accented_characters($this->title), 'dash')), '-', true);
     if (empty($slug)) {
         $t = new Text();
         $max = $t->select_max('id')->get();
         $slug = $max->id + 1;
     }
     if (is_numeric($slug)) {
         $slug = "{$slug}-1";
     }
     if ($this->slug === $slug || !empty($this->slug) && $this->slug !== '__generate__') {
         return;
     }
     $s = new Slug();
     // Need to lock the table here to ensure that requests arriving at the same time
     // still get unique slugs
     if ($this->has_db_permission('lock tables')) {
         $this->db->query("LOCK TABLE {$s->table} WRITE");
         $locked = true;
     } else {
         $locked = false;
     }
     $page_type = is_numeric($this->page_type) ? $this->page_type : 0;
     $prefix = $page_type === 1 ? 'page' : 'essay';
     while ($s->where('id', "{$prefix}.{$slug}")->count() > 0) {
         $slug = increment_string($slug, '-');
     }
     $this->db->query("INSERT INTO {$s->table}(id) VALUES ('{$prefix}.{$slug}')");
     if ($locked) {
         $this->db->query('UNLOCK TABLES');
     }
     $this->slug = $slug;
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:38,代码来源:text.php


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