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


PHP IModel::query_sql方法代码示例

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


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

示例1: seo_items

 public function seo_items($item)
 {
     $weburl = IUrl::getHost() . IUrl::creatUrl("");
     switch ($item) {
         case 'blist':
             $query = new IQuery('brand');
             $query->fields = "id";
             $items = $query->find();
             $lastmod = date('Y-m-d');
             //对url进行处理
             foreach ($items as $key => $val) {
                 $items[$key]['loc'] = IUrl::getHost() . '/blist/' . $val['id'] . '.html';
                 $items[$key]['lastmod'] = $lastmod;
             }
             SiteMaps::create_map($items, 'sitemap_blist.xml', $weburl . 'sitemaps.xsl');
         case 'glist':
             $lastmod = date('Y-m-d');
             // 获取二级类
             $categoryObj = new IModel('category');
             // 获取前四个分类
             $sql = "SELECT id,name,parent_id FROM {$this->tablePre}category WHERE parent_id IN (SELECT id FROM {$this->tablePre}category WHERE parent_id=-1 ) ";
             $items = $categoryObj->query_sql($sql);
             //对url进行处理
             foreach ($items as $key => $val) {
                 $items[$key]['loc'] = IUrl::getHost() . '/glist/' . $val['parent_id'] . '_' . $val['id'] . '.html';
                 $items[$key]['lastmod'] = $lastmod;
             }
             SiteMaps::create_map($items, 'sitemap_glist.xml', $weburl . 'sitemaps.xsl');
         case 'article':
             $lastmod = date('Y-m-d');
             // 获取二级类
             $categoryObj = new IModel('category');
             // 获取前四个分类
             $sql = "SELECT id FROM {$this->tablePre}article WHERE 1 ";
             $items = $categoryObj->query_sql($sql);
             //对url进行处理
             foreach ($items as $key => $val) {
                 $items[$key]['loc'] = IUrl::getHost() . '/article/' . $val['id'] . '.html';
                 $items[$key]['lastmod'] = $lastmod;
             }
             SiteMaps::create_map($items, 'sitemap_article.xml', $weburl . 'sitemaps.xsl');
     }
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:43,代码来源:tools.php

示例2: blist

 public function blist()
 {
     $data = array();
     $ids = IFilter::act(IReq::get('ids'));
     if ($ids) {
         $arr_ids = explode('_', $ids);
         $bid = isset($arr_ids[0]) ? intval($arr_ids[0]) : 0;
         $sort = isset($arr_ids[1]) ? intval($arr_ids[1]) : 0;
         $page = isset($arr_ids[2]) ? intval($arr_ids[2]) : 0;
     } else {
         $bid = IFilter::act(IReq::get('bid'));
         $page = IFilter::act(IReq::get('page'), 'int');
         $sort = IFilter::act(IReq::get('sort'), 'int');
     }
     $sort = $sort > count($this->sort_type_map) - 1 ? count($this->sort_type_map) - 1 : $sort;
     $pagesize = $this->site_config['list_num'];
     $start = $page * $pagesize;
     $order_by = $this->sort_type_map[$sort] ? $this->sort_type_map[$sort] : "{$this->tablePre}goods.sort ASC";
     $goods_list = array();
     if ($bid) {
         $where = "{$this->tablePre}goods.is_del=0 AND {$this->tablePre}goods.brand_id={$bid}";
         $tb_goods = new IModel('goods');
         // 取商品总数
         $sql = "SELECT DISTINCT({$this->tablePre}goods.id) \n\t\t\t\t\tFROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}goods.id = {$this->tablePre}category_extend.goods_id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}brand ON {$this->tablePre}brand.id={$this->tablePre}goods.brand_id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category_extend.category_id = {$this->tablePre}category.id\n\t\t\t\t\tWHERE {$where}";
         $all_goods_list = $tb_goods->query_sql($sql);
         $sql = "SELECT DISTINCT({$this->tablePre}goods.id),{$this->tablePre}goods.*,{$this->tablePre}brand.name as bname \n\t\t\t\tFROM {$this->tablePre}goods\n\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}goods.id = {$this->tablePre}category_extend.goods_id\n\t\t\t\tLEFT JOIN {$this->tablePre}brand ON {$this->tablePre}brand.id={$this->tablePre}goods.brand_id\n\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category_extend.category_id = {$this->tablePre}category.id\n\t\t\t\tWHERE {$where}\n\t\t\t\tORDER BY {$order_by}\n\t\t\t\tLIMIT {$start},{$pagesize}";
         $goods_list = $tb_goods->query_sql($sql);
     }
     $data['title'] = count($goods_list) > 0 ? '品牌' . $goods_list[0]['bname'] . '商品列表' : '';
     $data['description'] = '';
     $data['keywords'] = '';
     $data['goods_list'] = $goods_list;
     $data['bname'] = count($goods_list) > 0 ? $goods_list[0]['bname'] : '';
     $data['sort'] = $sort;
     $data['kw'] = '';
     $data['bid'] = $bid;
     $data['page'] = $page;
     $data['pagesize'] = $pagesize;
     $data['goodsNum'] = count($all_goods_list);
     $this->setRenderData($data);
     $this->redirect('blist');
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:42,代码来源:frontend.php


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