本文整理汇总了PHP中CGlobal::item_condition方法的典型用法代码示例。如果您正苦于以下问题:PHP CGlobal::item_condition方法的具体用法?PHP CGlobal::item_condition怎么用?PHP CGlobal::item_condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGlobal
的用法示例。
在下文中一共展示了CGlobal::item_condition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
function __construct()
{
Form::Form('FilterMenuSearchForm');
$this->filter_get = Url::get('filter');
$this->search_catid = (int) Url::get('search_catid', -1);
if ($this->search_catid <= 0 || !isset(CGlobal::$allCategories[$this->search_catid]) || CGlobal::$allCategories[$this->search_catid]['status'] == 'HIDE') {
$this->search_catid = 0;
}
$keywords = AZLib::getParam('keywords');
if ($this->search_catid && $keywords != '') {
if (isset(CGlobal::$filters[$this->search_catid])) {
$this->filter_groups = CGlobal::$filters[$this->search_catid];
}
$curCategory = CGlobal::$allCategories[$this->search_catid];
if ($curCategory['parent_id'] && isset(CGlobal::$allCategories[$curCategory['parent_id']])) {
$parent_cat = CGlobal::$allCategories[$curCategory['parent_id']];
$this->search_top_catid = $curCategory['parent_id'];
$this->search_sec_catid = $this->search_catid;
} else {
$this->search_top_catid = $this->search_catid;
}
#############################################################################################################################################
#Search condition
if ($this->search_sec_catid) {
CGlobal::$item_condition = "level_2_catid = " . $this->search_sec_catid . " AND ";
} elseif ($this->search_top_catid) {
CGlobal::$item_condition = "level_1_catid = " . $this->search_top_catid . " AND ";
}
CGlobal::$item_condition .= "status = 1";
//CGlobal::$item_condition .="status = 1 AND filter_ids != ''";
$arr = explode(' ', $keywords);
if ($arr) {
$keywords = '';
foreach ($arr as $keyword) {
if (trim($keyword) != '') {
$keywords .= ($keywords == '' ? '+' : ' +') . trim($keyword);
}
}
}
//CGlobal::$item_condition .= ' AND MATCH(name, list_brief, brief, description) AGAINST (\'*'.$keywords.'*\' IN BOOLEAN MODE) HAVING relevance > 0.2';
//CGlobal::$item_condition .= " AND MATCH(name) AGAINST ('*$keywords*' IN BOOLEAN MODE)";
CGlobal::$item_condition .= " AND MATCH(name, list_brief, brief, description) AGAINST ('{$keywords}' IN BOOLEAN MODE)";
$filter_get = $this->filter_get;
$this->filter_get = array();
$filter_str = '';
if ($this->filter_groups) {
foreach ($this->filter_groups as $fgid => $gfilter) {
if ($filter_get && isset($filter_get[$fgid]) && $filter_get[$fgid]) {
$fid = $filter_get[$fgid];
if ($gfilter['filters'] && in_array($fid, array_keys($gfilter['filters']))) {
CGlobal::$no_paging = true;
$this->filter_get[$fgid] = $fid;
$filter_str .= ($filter_str == '' ? '+' : ' +') . "g{$fgid}f{$fid}f";
}
}
}
}
$price_str = CGlobal::$allCategories[$this->search_catid]['price_str'];
if ($price_str) {
$filter_price = array();
$arr = explode(',', $price_str);
$link = Url::build_all(array('filter', 'max', 'min'));
if ($this->filter_get) {
foreach ($this->filter_get as $get_gid => $get_fid) {
$link .= "&filter[{$get_gid}]={$get_fid}";
}
}
//SELECT SUM((price < 2000000 AND currency_id=1) OR ((price* 18000)< 200000 AND currency_id=2)) AS filter,
//SUM((price >= 2000000 AND price< 5000000 AND currency_id=1) OR ((price* 18000) >= 200000 AND (price* 18000) < 500000 AND currency_id=2)) AS filter
//FROM products
$last_price = 0;
$get_min = (int) Url::get('min', 0);
$get_max = (int) Url::get('max', 0);
$i = 1;
foreach ($arr as $price) {
if ($last_price == 0) {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `0`";
} else {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price >= {$last_price} AND price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND (price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `{$last_price}`";
}
if ($get_min == $last_price && $get_max == $price) {
$this->min = $get_min;
$this->max = $get_max;
}
$filter_price[] = array('min' => $last_price, 'max' => $price);
$last_price = $price;
$i++;
}
if ($last_price) {
if ($get_min == $last_price && $get_max == 0) {
$this->min = $get_min;
$this->max = 0;
}
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . "SUM((price >= {$last_price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND currency_id=2)) AS `{$last_price}`";
$filter_price[] = array('min' => $last_price, 'max' => 0);
$last_price = $price;
}
if ($this->min) {
CGlobal::$item_condition .= " AND ((price >= " . $this->min . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= " . $this->min . " AND currency_id=2))";
}
//.........这里部分代码省略.........
示例2: elseif
function __construct()
{
Form::Form('FilterMenuForm');
$this->filter_get = Url::get('filter');
if (CGlobal::$curCategory && isset(CGlobal::$filters[CGlobal::$curCategory])) {
$this->filter_groups = CGlobal::$filters[CGlobal::$curCategory];
}
#############################################################################################################################################
#Search condition
if (CGlobal::$curLevel2Cat) {
CGlobal::$item_condition = "level_2_catid = " . CGlobal::$curLevel2Cat['id'] . " AND ";
} elseif (CGlobal::$curMainCat) {
CGlobal::$item_condition = "level_1_catid = " . CGlobal::$curMainCat['id'] . " AND ";
}
CGlobal::$item_condition .= "status = 1";
//CGlobal::$item_condition .="status = 1 AND filter_ids != ''";
$filter_get = $this->filter_get;
$this->filter_get = array();
$filter_str = '';
if ($this->filter_groups) {
foreach ($this->filter_groups as $fgid => $gfilter) {
if ($filter_get && isset($filter_get[$fgid]) && $filter_get[$fgid]) {
$fid = $filter_get[$fgid];
if ($gfilter['filters'] && in_array($fid, array_keys($gfilter['filters']))) {
CGlobal::$no_paging = true;
$this->filter_get[$fgid] = $fid;
$filter_str .= ($filter_str == '' ? '+' : ' +') . "g{$fgid}f{$fid}f";
}
}
}
}
if (CGlobal::$curCategory && isset(CGlobal::$allCategories[CGlobal::$curCategory])) {
$price_str = CGlobal::$allCategories[CGlobal::$curCategory]['price_str'];
if ($price_str) {
$filter_price = array();
$arr = explode(',', $price_str);
$link = WEB_DIR . "c" . CGlobal::$curCategory . "/" . Url::get('ebname');
if ($this->filter_get) {
foreach ($this->filter_get as $get_gid => $get_fid) {
$link .= "&filter[{$get_gid}]={$get_fid}";
}
}
//SELECT SUM((price < 2000000 AND currency_id=1) OR ((price* 18000)< 200000 AND currency_id=2)) AS filter,
//SUM((price >= 2000000 AND price< 5000000 AND currency_id=1) OR ((price* 18000) >= 200000 AND (price* 18000) < 500000 AND currency_id=2)) AS filter
//FROM products
$last_price = 0;
$get_min = (int) Url::get('min', 0);
$get_max = (int) Url::get('max', 0);
$i = 1;
foreach ($arr as $price) {
if ($last_price == 0) {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `0`";
} else {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price >= {$last_price} AND price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND (price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `{$last_price}`";
}
if ($get_min == $last_price && $get_max == $price) {
$this->min = $get_min;
$this->max = $get_max;
}
$filter_price[] = array('min' => $last_price, 'max' => $price);
$last_price = $price;
$i++;
}
if ($last_price) {
if ($get_min == $last_price && $get_max == 0) {
$this->min = $get_min;
$this->max = 0;
}
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . "SUM((price >= {$last_price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND currency_id=2)) AS `{$last_price}`";
$filter_price[] = array('min' => $last_price, 'max' => 0);
$last_price = $price;
}
if ($this->min) {
CGlobal::$item_condition .= " AND ((price >= " . $this->min . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= " . $this->min . " AND currency_id=2))";
}
if ($this->max) {
CGlobal::$item_condition .= " AND ((price < " . $this->max . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < " . $this->max . " AND currency_id=2))";
}
}
if ($filter_str) {
CGlobal::$item_condition .= " AND MATCH(filter_search) AGAINST ('{$filter_str}' IN BOOLEAN MODE)";
}
#############################################################################################################################################
if ($this->price_cout_str) {
$this->filter_price = array('name' => "Giới hạn theo giá (VNĐ)", 'filters' => array());
$price_cout_arr = DB::fetch("SELECT " . $this->price_cout_str . " FROM item WHERE " . CGlobal::$item_condition);
if ($filter_price) {
foreach ($filter_price as $fprice) {
$min = $fprice['min'];
$max = $fprice['max'];
if ($price_cout_arr[$min]) {
if ($min && $max) {
$link2 = "{$link}&min={$min}&max={$max}";
$name = AZLib::money($min) . " - " . AZLib::money($max);
} elseif (!$max) {
$link2 = "{$link}&min={$min}";
$name = "Trên " . AZLib::money($min);
} elseif (!$min) {
$link2 = "{$link}&max={$max}";
$name = "Dưới " . AZLib::money($max);
//.........这里部分代码省略.........
示例3: BuildForm
function BuildForm()
{
Form::Form('BuildForm');
CGlobal::$website_title = "Xây dựng cấu hình máy tính";
if (Build::$bcatid) {
$this->filter_get = Url::get('filter');
AZLib::getFilters();
if (isset(CGlobal::$filters[Build::$bcatid])) {
$this->filter_groups = CGlobal::$filters[Build::$bcatid];
}
#############################################################################################################################################
#Search condition
CGlobal::$item_condition = "category_id = " . Build::$bcatid . " AND quantity>0 AND status = 1 AND price>0 AND quantity>0";
//CGlobal::$item_condition .="status = 1 AND filter_ids != ''";
$filter_str = '';
if (isset(CGlobal::$filters[Build::$bcatid])) {
$this->filter_groups = CGlobal::$filters[Build::$bcatid];
$filter_get = $this->filter_get;
$this->filter_get = array();
if ($this->filter_groups) {
foreach ($this->filter_groups as $fgid => $gfilter) {
if ($filter_get && isset($filter_get[$fgid]) && $filter_get[$fgid]) {
$fid = $filter_get[$fgid];
if ($gfilter['filters'] && in_array($fid, array_keys($gfilter['filters']))) {
CGlobal::$no_paging = true;
$this->filter_get[$fgid] = $fid;
$filter_str .= ($filter_str == '' ? '+' : ' +') . "g{$fgid}f{$fid}f";
}
}
}
}
}
$price_str = CGlobal::$allCategories[Build::$bcatid]['price_str'];
if ($price_str) {
$filter_price = array();
$arr = explode(',', $price_str);
$link = AZRewrite::formatUrl(Url::build_all(array('min', 'max', 'filter', 'page_no')));
if ($this->filter_get) {
foreach ($this->filter_get as $get_gid => $get_fid) {
$link .= "&filter[{$get_gid}]={$get_fid}";
}
}
//SELECT SUM((price < 2000000 AND currency_id=1) OR ((price* 18000)< 200000 AND currency_id=2)) AS filter,
//SUM((price >= 2000000 AND price< 5000000 AND currency_id=1) OR ((price* 18000) >= 200000 AND (price* 18000) < 500000 AND currency_id=2)) AS filter
//FROM products
$last_price = 0;
$get_min = (int) Url::get('min', 0);
$get_max = (int) Url::get('max', 0);
$i = 1;
foreach ($arr as $price) {
if ($last_price == 0) {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `0`";
} else {
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price >= {$last_price} AND price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND (price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `{$last_price}`";
}
if ($get_min == $last_price && $get_max == $price) {
$this->min = $get_min;
$this->max = $get_max;
}
$filter_price[] = array('min' => $last_price, 'max' => $price);
$last_price = $price;
$i++;
}
if ($last_price) {
if ($get_min == $last_price && $get_max == 0) {
$this->min = $get_min;
$this->max = 0;
}
$this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . "SUM((price >= {$last_price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND currency_id=2)) AS `{$last_price}`";
$filter_price[] = array('min' => $last_price, 'max' => 0);
$last_price = $price;
}
if ($this->min) {
CGlobal::$item_condition .= " AND ((price >= " . $this->min . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= " . $this->min . " AND currency_id=2))";
}
if ($this->max) {
CGlobal::$item_condition .= " AND ((price < " . $this->max . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < " . $this->max . " AND currency_id=2))";
}
}
if ($filter_str) {
CGlobal::$item_condition .= " AND MATCH(filter_search) AGAINST ('{$filter_str}' IN BOOLEAN MODE)";
}
#############################################################################################################################################
if ($this->price_cout_str) {
$this->filter_price = array('name' => "Giới hạn theo giá (VNĐ)", 'filters' => array());
$price_cout_arr = DB::fetch("SELECT " . $this->price_cout_str . " FROM item WHERE " . CGlobal::$item_condition);
if ($filter_price) {
foreach ($filter_price as $fprice) {
$min = $fprice['min'];
$max = $fprice['max'];
if ($price_cout_arr[$min]) {
if ($min && $max) {
$link2 = "{$link}&min={$min}&max={$max}";
$name = AZLib::money($min) . " - " . AZLib::money($max);
} elseif (!$max) {
$link2 = "{$link}&min={$min}";
$name = "Trên " . AZLib::money($min);
} elseif (!$min) {
$link2 = "{$link}&max={$max}";
$name = "Dưới " . AZLib::money($max);
//.........这里部分代码省略.........
示例4: elseif
function draw_from()
{
//mb_internal_encoding("UTF-8");
//AZLib::getCats();
AZLib::getProvinces();
global $display;
$page_no = (int) Url::get('page_no', 1);
if ($page_no <= 0) {
$page_no = 1;
}
$admin_item = FALSE;
if (User::have_permit(ADMIN_ITEM)) {
$admin_item = TRUE;
}
$item_per_page = 30;
$sql = 'SELECT * FROM item WHERE ';
$where = '';
$curMainCat = CGlobal::$curMainCat;
$curLevel2Cat = CGlobal::$curLevel2Cat;
/*if($curLevel2Cat){
$where .=($where!=''?" AND ":"")." level_2_catid = ".$curLevel2Cat['id'];
}
elseif($curMainCat){
$where .=($where!=''?" AND ":"")." level_1_catid = ".$curMainCat['id'];
}
$where .= ($where!=''?" AND ":"")." status=1";
$sql .= "$where ORDER BY item_order ASC";*/
if (!CGlobal::$item_condition) {
//Ngannv hack code trường hợp khong add module FilterMenu hoặc module Build
if (isset($_GET['category_id']) && $_GET['category_id']) {
CGlobal::$item_condition = " category_id = " . CGlobal::$curCategory . " ";
}
}
$sql .= CGlobal::$item_condition . " ORDER BY item_order ASC";
$total_row = DB::count("item", CGlobal::$item_condition);
if (CGlobal::$allCategories[CGlobal::$curCategory]['parent_id'] && isset(CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']])) {
$ebname = CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']]['ebname'] . '-' . CGlobal::$allCategories[CGlobal::$curCategory]['ebname'];
} else {
$ebname = CGlobal::$allCategories[CGlobal::$curCategory]['ebname'];
}
#######################################################################################
#Paging
$url_new = "?page=list_detail&category_id=" . CGlobal::$curCategory . "&ebname=" . $ebname;
$url_addend = "";
$filter_get = Url::get('filter');
$min = Url::get('min');
$max = Url::get('max');
$order = Url::get('order');
if ($filter_get) {
foreach ($filter_get as $get_gid => $get_fid) {
$url_addend .= ($url_addend != '' ? '&' : '?') . "filter[{$get_gid}]={$get_fid}";
}
}
if ($min) {
$url_addend .= ($url_addend != '' ? '&' : '?') . "min={$min}";
}
if ($max) {
$url_addend .= ($url_addend != '' ? '&' : '?') . "max={$max}";
}
if ($order) {
$url_addend .= ($url_addend != '' ? '&' : '?') . "order={$order}";
}
$limit = '';
$paging = AZPagging::paging_list($limit, $total_row, $item_per_page, 10, 'page_no', $url_new, TRUE, 'Sản phẩm', 'Trang', $url_addend);
//$paging = AZPagging::paging_list($limit,$item_per_page,'page_no',$url_new);
$sql .= $limit;
#Paging
#######################################################################################
$items = array();
$re = DB::query($sql);
if ($re) {
while ($item = mysql_fetch_assoc($re)) {
$items[$item['id']] = $this->processItem($item, $admin_item);
}
}
$display->add('admin_item', $admin_item);
$display->add('page', $page_no);
$display->add('items', $items);
$display->add('paging', $paging);
$display->output("ListItem");
}