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


PHP Content::query方法代码示例

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


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

示例1: children

 function children($section = '', $cell = '')
 {
     // getting the section path to the main index page
     if (!empty($section)) {
         $par_sec = $section->get_parents();
     }
     // selecting all the content of that parent
     $sql_stat = "SELECT * FROM `content` WHERE `parent_content`= {$this->id}";
     // filter the objects to the requested cell
     if ($cell !== '') {
         $sql_stat .= " AND `cell`={$cell}";
     }
     /***************************************
      *  filter the objects to the requested section
      * and all the parent sections that the content requested to be 
      * shared in the sub sections ordered in ascending with sort field
      * **************************************/
     if (!empty($section)) {
         $sql_stat .= " AND \r\n\t\t\t(\r\n\t\t\t\t(`parent_section`={$section->id})";
         if (count($par_sec) > 0) {
             $sql_stat .= sprintf(" OR (`parent_section` IN (%s) AND `subsection`=%s)", implode(',', $par_sec), intval(TRUE));
         }
         $sql_stat .= ") ORDER BY `sort` ASC";
     }
     // submit the query
     $children = new Content();
     $children->query($sql_stat);
     // returning the final array of children
     return $children->all;
 }
开发者ID:sigit,项目名称:vunsy,代码行数:30,代码来源:content.php

示例2: covers

 function covers()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $params['auth'] = $this->auth;
     // Standard add/delete cover
     list($id, $content_id) = $id;
     if ($this->method === 'get') {
         $this->redirect("/albums/{$id}");
     }
     $a = new Album($id);
     $c = new Content();
     if (!$a->exists()) {
         $this->error('404', 'Album not found.');
         return;
     }
     $cover_count = $a->covers->count();
     if ($cover_count > 50) {
         $this->error('403', 'Only 50 covers can be added to any one album.');
         return;
     }
     if ($a->album_type == 2 && $cover_count == 0) {
         $subs = new Album();
         $subs->select('id')->where('right_id <', $a->right_id)->where('left_id >', $a->left_id)->where('visibility', $a->visibility)->get_iterated();
         $id_arr = array();
         foreach ($subs as $sub) {
             $id_arr[] = $sub->id;
         }
         if (!empty($id_arr)) {
             $subc = new Content();
             $covers = $subc->query("SELECT DISTINCT cover_id FROM {$a->db_join_prefix}albums_covers WHERE album_id IN (" . join(',', $id_arr) . ") GROUP BY album_id LIMIT " . (3 - $cover_count));
             $f_ids = array();
             foreach ($covers as $f) {
                 $f_ids[] = $f->cover_id;
             }
             if (!empty($f_ids)) {
                 $subc->query("SELECT id FROM {$subc->table} WHERE id IN(" . join(',', $f_ids) . ") ORDER BY FIELD(id, " . join(',', array_reverse($f_ids)) . ")");
                 foreach ($subc as $content) {
                     $a->save_cover($content);
                 }
             }
         }
     }
     if (is_numeric($content_id)) {
         if ($this->method == 'delete') {
             $c->where_related('covers', 'id', $id)->get_by_id($content_id);
         } else {
             if ($a->album_type == 2) {
                 $c->get_by_id($content_id);
             } else {
                 $c->where_related('album', 'id', $id)->get_by_id($content_id);
             }
         }
         if (!$c->exists()) {
             $this->error('404', 'Content not found.');
             return;
         }
         if ($this->method == 'delete') {
             $a->delete_cover($c);
             $a->reset_covers();
         } else {
             $a->delete_cover($c);
             $a->save_cover($c);
         }
     } else {
         $content_id = explode(',', $content_id);
         if ($this->method == 'delete') {
             $c->where_related('covers', 'id', $id)->where_in('id', $content_id)->get_iterated();
         } else {
             if ($a->album_type == 2) {
                 $c->where_in('id', $content_id)->get_iterated();
             } else {
                 $c->where_related('album', 'id', $id)->where_in('id', $content_id)->get_iterated();
             }
         }
         if (!$c->result_count()) {
             $this->error('404', 'Content not found.');
             return;
         }
         if ($this->method == 'delete') {
             foreach ($c as $cover) {
                 $a->delete_cover($cover);
             }
             $a->reset_covers();
         } else {
             foreach ($c as $cover) {
                 $a->delete_cover($cover);
             }
             foreach ($content_id as $cid) {
                 $a->save_cover($c->get_by_id($cid));
             }
         }
     }
     $this->redirect("/albums/{$id}");
 }
开发者ID:Caldis,项目名称:htdocs,代码行数:94,代码来源:albums.php

示例3: children

 function children($section = '', $cell = '')
 {
     // getting the section path to the main index page
     if (!empty($section)) {
         $par_sec = $section->get_parents();
     }
     // selecting all the content of that parent
     $sql_stat = "SELECT * FROM `content` WHERE `parent_content`= {$this->id}";
     // filter the objects to the requested cell
     if (isset($cell) and $cell != '') {
         $sql_stat .= " AND `cell`={$cell}";
     }
     /***************************************
      *  filter the objects to the requested section
      * and all the parent sections that the content requested to be 
      * shared in the sub sections ordered in ascending with sort field
      * **************************************/
     if (!empty($section)) {
         $sql_stat .= " AND \r\n\t\t\t(\r\n\t\t\t\t(`parent_section`={$section->id})";
         if (count($par_sec) > 0) {
             $sql_stat .= sprintf(" OR (`parent_section` IN (%s) AND `subsection`=%s)", implode(',', $par_sec), intval(TRUE));
         }
         $sql_stat .= ") ORDER BY `sort` ASC";
     }
     // submit the query
     $children = new Content();
     $children->query($sql_stat);
     /***************************************
      * building the children array with the respect objects
      * in other meaning we'll convert all the content to their 
      * subtype : layout, widgets, ... etc
      * **************************************/
     $final_c = array();
     // final array of children to return them
     foreach ($children->all as $item) {
         // making the content object with the type
         if (class_exists($item->type)) {
             $temp = new $item->type();
         } else {
             $temp = new Content();
         }
         $temp->get_by_id($item->id);
         array_push($final_c, $temp);
     }
     // returning the final array of children
     return $final_c;
 }
开发者ID:blumine,项目名称:vunsy,代码行数:47,代码来源:layout.php

示例4: array

 function to_array($options = array())
 {
     $options = array_merge(array('with_covers' => true, 'auth' => false), $options);
     $koken_url_info = $this->config->item('koken_url_info');
     $exclude = array('deleted', 'total_count', 'video_count', 'featured_order', 'tags_old', 'old_slug');
     $dates = array('created_on', 'modified_on', 'featured_on', 'published_on');
     $strings = array('title', 'summary', 'description');
     $bools = array('featured');
     list($data, $public_fields) = $this->prepare_for_output($options, $exclude, $bools, $dates, $strings);
     if (!$options['auth'] && $data['visibility'] < 1) {
         unset($data['internal_id']);
     }
     if (!$data['featured']) {
         unset($data['featured_on']);
     }
     $sort = array();
     list($sort['by'], $sort['direction']) = explode(' ', $data['sort']);
     $data['sort'] = $sort;
     $data['__koken__'] = 'album';
     if (array_key_exists('album_type', $data)) {
         switch ($data['album_type']) {
             case 2:
                 $data['album_type'] = 'set';
                 break;
             case 1:
                 $data['album_type'] = 'smart';
                 break;
             default:
                 $data['album_type'] = 'standard';
         }
     }
     if ($this->album_type == 2) {
         $sum = new Album();
         $sum->select_sum('total_count')->select_sum('video_count')->where('right_id <', $this->right_id)->where('left_id >', $this->left_id)->where('album_type', 0)->where('visibility', 0)->get();
         $data['counts'] = array('total' => (int) $this->total_count, 'videos' => (int) $sum->video_count, 'images' => $sum->total_count - $sum->video_count);
     } else {
         $data['counts'] = array('total' => (int) $this->total_count, 'videos' => (int) $this->video_count, 'images' => $this->total_count - $this->video_count);
     }
     $data['tags'] = $this->_get_tags_for_output($options);
     $data['categories'] = array('count' => is_null($this->category_count) ? $this->categories->count() : (int) $this->category_count, 'url' => $koken_url_info->base . 'api.php?/albums/' . $data['id'] . '/categories');
     $data['topics'] = array('count' => is_null($this->text_count) ? $this->text->count() : (int) $this->text_count, 'url' => $koken_url_info->base . 'api.php?/albums/' . $data['id'] . '/topics');
     if ($options['with_covers']) {
         $data['covers'] = $existing = array();
         $covers = $this->covers;
         if (isset($options['before'])) {
             $covers->where('published_on <=', $options['before']);
             $data['__cover_hint_before'] = $options['before'];
         }
         $covers->include_related_count('albums', NULL, array('visibility' => 0));
         $covers->include_related_count('categories');
         foreach ($covers->order_by("covers_{$this->db_join_prefix}albums_covers.id ASC")->get_iterated() as $f) {
             if ($f->exists()) {
                 $data['covers'][] = $f->to_array(array('in_album' => $this));
                 $existing[] = $f->id;
             }
         }
         $covers_count_set = false;
         if ($this->album_type == 2) {
             $covers_count_set = $this->covers->count();
         }
         if ($covers_count_set !== false && $covers_count_set < 3) {
             $a = new Album();
             $ids = $a->select('id')->where('right_id <', $this->right_id)->where('left_id >', $this->left_id)->where('visibility', $this->visibility)->get_iterated();
             $id_arr = array();
             foreach ($ids as $id) {
                 $id_arr[] = $id->id;
             }
             if (!empty($id_arr)) {
                 $c = new Content();
                 $q = "SELECT DISTINCT cover_id FROM {$this->db_join_prefix}albums_covers WHERE album_id IN (" . join(',', $id_arr) . ")";
                 if (!empty($existing)) {
                     $q .= ' AND cover_id NOT IN(' . join(',', $existing) . ')';
                 }
                 $covers = $c->query($q . "GROUP BY album_id LIMIT " . (3 - $covers_count_set));
                 $f_ids = array();
                 foreach ($covers as $f) {
                     $f_ids[] = $f->cover_id;
                 }
                 if (!empty($f_ids)) {
                     $c->where_in('id', $f_ids)->get_iterated();
                     foreach ($c as $content) {
                         // TODO: auth needs to be passed in here
                         array_unshift($data['covers'], $content->to_array(array('in_album' => $this)));
                     }
                 }
             }
         }
         // Latest covers first
         $data['covers'] = array_reverse($data['covers']);
     }
     if (isset($options['order_by']) && in_array($options['order_by'], array('created_on', 'modified_on'))) {
         $data['date'] =& $data[$options['order_by']];
     } else {
         $data['date'] =& $data['published_on'];
     }
     if ($data['level'] > 1 && (!array_key_exists('include_parent', $options) || $options['include_parent'])) {
         $parent = new Album();
         $parent->where('left_id <', $data['left_id'])->where('level <', $data['level'])->where('visibility', $this->visibility)->where('deleted', 0)->order_by('left_id DESC')->limit(1)->get();
         $data['parent'] = $parent->to_array();
     } else {
//.........这里部分代码省略.........
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:101,代码来源:album.php

示例5: showProjeto

 /**
  * /
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function showProjeto($id)
 {
     $result = Content::query($this->db, 'showPublished', $id);
     if ($result->isSuccessful()) {
         $this->renderArray['content'] = $result->getRecords();
     }
 }
开发者ID:pedrokoblitz,项目名称:maltz,代码行数:12,代码来源:SecultSiteDataView.php


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