本文整理汇总了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;
}
示例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);
}