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


PHP Am_Query::innerJoin方法代码示例

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


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

示例1: createQuery

 /**
  * return query object with category filter applied if specified
  * if parameters === 0, it selects products not assigned to any categories
  * if parameter === null, it selects products regardless of categories
  * @param int $product_category_id
  * @param bool $include_hidden  Include products from hidden categories.
  * @return Am_Query
  */
 function createQuery($product_category_id = null, $include_hidden = true)
 {
     $q = new Am_Query($this, 'p');
     $q->addOrderRaw('0+p.sort_order')->addOrder('title');
     $q->addWhere('p.is_disabled=0');
     if ($product_category_id > 0) {
         $q->innerJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id AND ppc.product_category_id=' . intval($product_category_id));
     } elseif ((string) $product_category_id === '0') {
         $q->leftJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id')->addHaving('count(ppc.product_category_id)=0');
     } elseif (!$include_hidden) {
         $q->leftJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id')->leftJoin('?_product_category', 'pc', 'pc.product_category_id = ppc.product_category_id')->addHaving('sum(if(pc.code>"", 1, 0)) =0');
     }
     return $q;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:22,代码来源:Product.php

示例2: applySimpleSearch

 function applySimpleSearch()
 {
     $search = array();
     foreach ($this->options as $string) {
         @(list($k, $id) = explode('-', $string, 2));
         $search[$k][] = $id == 'all' ? 'all' : intval($id);
     }
     $queries = array();
     // union these queries with $this->query
     $this->queryDescription = array();
     foreach ($search as $k => $items) {
         if ($k == 'all') {
             $q = new Am_Query_User();
             $q->addWhere("IFNULL(u.unsubscribed,0)=0");
             $queries = array($q);
             $this->queryDescription = array(___("All Users"));
             break;
         }
         switch ($k) {
             case 'aff':
                 $q = new Am_Query_User();
                 $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                 $q->addWhere("is_affiliate>0");
                 $queries[] = $q;
                 $this->queryDescription[] = ___("All Affiliates");
                 break;
             case 'active':
             case 'expired':
                 $q = new Am_Query_User();
                 $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                 $product_ids = in_array('all', $items) ? null : $items;
                 $q->add(new Am_Query_User_Condition_HaveSubscriptionTo($product_ids, $k == 'expired' ? User::STATUS_EXPIRED : User::STATUS_ACTIVE));
                 $queries[] = $q;
                 $this->queryDescription[] = ($k == 'expired' ? ___("Expired Users") : ___("Active Users")) . ($product_ids ? " " . ___("of products") . " " . join(",", $product_ids) : null);
                 break;
             case 'newsletter':
                 if (Am_Di::getInstance()->modules->isEnabled('newsletter')) {
                     $q = new Am_Query_User();
                     $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                     $q->add(new Am_Query_User_Condition_SubscribedToNewsletter($items));
                     $queries[] = $q;
                     $this->queryDescription[] = ___("Users subscribed to Newsletter Threads #") . join(',', $items);
                 }
                 break;
         }
     }
     if (@$search['guest'] || @$search['newsletter']) {
         if (Am_Di::getInstance()->modules->isEnabled('newsletter')) {
             $q = new Am_Query(new NewsletterGuestTable(), 'g');
             if ($queries) {
                 $fields = Am_Di::getInstance()->userTable->getFields(true);
                 $q->clearFields();
                 $guestFields = array('name_f', 'name_l', 'email');
                 foreach ($fields as $k) {
                     $q->addField(in_array($k, $guestFields) ? $k : '(NULL)', $k);
                 }
             }
             $this->queryDescriptionGuest = ___("All Guests");
             if (!@$search['guest'] && @$search['newsletter']) {
                 $ids = join(',', $search['newsletter']);
                 $q->innerJoin('?_newsletter_guest_subscription', 'gs', "gs.guest_id=g.guest_id AND list_id IN ({$ids})");
                 $this->queryDescriptionGuest = ___("Guests having subscription to newsletters %s", $ids);
             }
             $queries[] = $q;
         }
     }
     if ($queries) {
         $this->query = array_shift($queries);
         foreach ($queries as $q) {
             $this->query->addUnion($q);
         }
     } else {
         $this->query->addWhere('0=1');
     }
     $this->queryDescription = join(' ,also ', $this->queryDescription);
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:76,代码来源:Ui.php


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