本文整理匯總了PHP中IQuery類的典型用法代碼示例。如果您正苦於以下問題:PHP IQuery類的具體用法?PHP IQuery怎麽用?PHP IQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IQuery類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: category_save
/**
* @brief 保存品牌分類
*/
function category_save()
{
$category_id = IFilter::act(IReq::get('category_id'), 'int');
$name = IFilter::act(IReq::get('name'));
$category_info = array();
$tb_brand_category = new IModel('brand_category');
$category_info['name'] = $name;
$tb_brand_category->setData($category_info);
if ($category_id) {
$where = "id=" . $category_id;
$tb_brand_category->update($where);
} else {
$tb_cate = new IQuery('brand_category');
//查詢數據庫,判斷該分類是否存在,如存在則不存儲
$tb_cate->fields = 'name';
$tb_info = $tb_cate->find();
if (count($tb_info) > 0) {
foreach ($tb_info as $value) {
if ($category_info['name'] == $value['name']) {
$this->redirect('category_edit', false);
Util::showMessage("添加的品牌分類已存在!");
}
}
}
$tb_brand_category->add();
}
$this->category_list();
}
示例2: paymentList
/**
* @brief 獲取所有已添加的支付插件
* @return array 返回支付插件
*/
public function paymentList()
{
$query = new IQuery('payment as a');
$query->join = " join pay_plugin as b on a.plugin_id = b.id";
$query->fields = " a.id,a.plugin_id,a.name,a.status,b.description,b.logo ";
$list = $query->find();
return $list;
}
示例3: getPropTongJi
public function getPropTongJi($propIds)
{
$query = new IQuery('prop');
$query->fields = "count(id) as prop_num";
$query->where = "id in (" . $propIds . ") and type = 0";
$info = $query->find();
return $info[0];
}
示例4: getOrderInfo
/**
* @brief 獲取訂單信息
* @param $orderId int 訂單ID
* @return array 訂單信息
*/
private static function getOrderInfo($orderId)
{
$orderDB = new IQuery('order as o');
$orderDB->fields = 'p.class_name,o.trade_no,dd.delivery_code,fc.freight_type,o.pay_type';
$orderDB->join = 'left join payment as p on o.pay_type = p.id left join delivery_doc as dd on o.id = dd.order_id left join delivery as d on d.id = o.distribution left join freight_company as fc on fc.id = dd.freight_id';
$orderDB->where = 'o.id = ' . $orderId;
$result = $orderDB->find();
return current($result);
}
示例5: setUser
private function setUser($user_id)
{
$user_id = intval($user_id);
$query = new IQuery("user AS u");
$query->join = "left join member AS m ON u.id = m.user_id";
$query->where = "u.id = {$user_id} ";
$user = $query->find();
if (!$user) {
$this->error[] = "沒有id為{$user_id}的用戶";
} else {
$this->user = current($user);
$this->time = date('Y-m-d H:i:s');
}
}
示例6: member_edit
/**
* @brief 添加會員
*/
function member_edit()
{
$uid = IFilter::act(IReq::get('uid'), 'int');
//編輯會員信息讀取會員信息
if ($uid) {
$userDB = new IQuery('user as u');
$userDB->join = 'left join member as m on u.id = m.user_id';
$userDB->where = 'u.id = ' . $uid;
$userInfo = $userDB->find();
if ($userInfo) {
$this->userInfo = current($userInfo);
} else {
$this->member_list();
Util::showMessage("沒有找到相關記錄!");
exit;
}
}
$this->redirect('member_edit');
}
示例7: getBrandListByGoodsCategoryId
public function getBrandListByGoodsCategoryId($id, $limit = 14)
{
$result = array();
$tb_brand_category = new IModel('brand_category');
$info = $tb_brand_category->query("goods_category_id=" . $id);
if ($info) {
$query = new IQuery('brand');
foreach ($info as $key => $val) {
$query->where = " FIND_IN_SET(" . $val['id'] . ",category_ids) ";
$query->order = 'sort asc';
$query->limit = $limit;
$list = $query->find();
$result = array_merge($result, $list);
if (count($result) >= $limit) {
$result = array_slice($result, 0, $limit);
break;
}
}
}
return $result;
}
示例8: get_comment_info
/**
* 獲取某個商品的有關分數的評論數據
*
* 獲取好評、中評、差評數量及平均分
* 返回的值裏包含以下幾個計算出來的索引
* <ul>
* <li>point_total,總分</li>
* <li>comment_total,評論總數</li>
* <li>average_point,平均分</li>
* </ul>
*
* @param int $id goods_id
* @return array()
*/
public static function get_comment_info($id)
{
$data = array();
$query = new IQuery("comment");
$query->fields = "COUNT(*) AS num,point";
$query->where = "goods_id = {$id} AND status=1 ";
$query->group = "point";
$data['point_grade'] = array('none' => 0, 'good' => 0, 'middle' => 0, 'bad' => 0);
$config = array(0 => 'none', '1' => 'bad', '2' => 'middle', 3 => 'middle', 4 => 'middle', 5 => 'good');
$data['point_total'] = 0;
foreach ($query->find() as $value) {
if ($value['point'] >= 0 && $value['point'] <= 5) {
$data['point_total'] += $value['point'] * $value['num'];
$data['point_grade'][$config[$value['point']]] += $value['num'];
}
}
$data['comment_total'] = array_sum($data['point_grade']);
$data['average_point'] = 0;
if ($data['point_total'] > 0) {
$data['average_point'] = round($data['point_total'] / $data['comment_total'], 1);
}
return $data;
}
示例9: refundment_show
function refundment_show()
{
//獲得post傳來的退款單id值
$refundment_id = IFilter::act(IReq::get('id'), 'int');
$data = array();
if ($refundment_id) {
$tb_refundment = new IQuery('refundment_doc as c');
$tb_refundment->join = ' left join order as o on c.order_id=o.id left join user as u on u.id = c.user_id';
$tb_refundment->fields = 'o.order_no,o.create_time,u.username,c.*';
$tb_refundment->where = 'c.id=' . $refundment_id . ' and seller_id = ' . $this->seller['seller_id'];
$refundment_info = $tb_refundment->find();
if ($refundment_info) {
$data = current($refundment_info);
$this->setRenderData($data);
$this->redirect('refundment_show', false);
}
}
if (!$data) {
$this->redirect('refundment_list');
}
}
示例10: getGoodsCategoryId
public static function getGoodsCategoryId($goods_id)
{
$gcQuery = new IQuery('category_extend as ce');
$gcQuery->join = "left join category as c on c.id = ce.category_id";
$gcQuery->where = "ce.goods_id = '{$goods_id}'";
$gcQuery->fields = 'c.id';
$gcList = $gcQuery->find();
$strCategoryIds = '';
foreach ($gcList as $val) {
$strCategoryIds .= $val['id'] . ',';
}
unset($gcQuery, $gcList);
return $strCategoryIds;
}
示例11: isset
</div>
</div>
<script type='text/javascript'>
//DOM加載完畢
$(function(){
//默認係統定義
select_tab("<?php
echo isset($this->confRow['form_index']) ? $this->confRow['form_index'] : "";
?>
");
show_mail(1);
//生成導航
<?php
$query = new IQuery("guide");
$guideList = $query->find();
foreach ($guideList as $key => $item) {
}
?>
<?php
if ($guideList) {
?>
var guideList = <?php
echo JSON::encode($guideList);
?>
;
for(var index in guideList)
{
add_guide(guideList[index]);
}
示例12: query
/**
* @brief 單純數據庫查詢api統一處理方法
* @param array $queryInfo 數據查詢配置信息
* @param array $aguments 排序和限製條數(order,limit)
* @return array
*/
private static function query($queryInfo, $aguments)
{
//參數重置order,limit參數
if (!empty($aguments)) {
foreach ($aguments as $param) {
if (is_numeric($param)) {
$queryInfo['limit'] = $param;
} else {
if (is_array($param)) {
//分頁模式
if ($param[0] == 'page') {
unset($queryInfo['limit']);
$queryInfo['page'] = $param[1];
} else {
$queryInfo['where'] = strtr($queryInfo['where'], array($param[0] => $param[1]));
}
} else {
$queryInfo['order'] = str_replace(array('+', '-'), array(' asc', ' desc'), $param);
}
}
}
}
$tableObj = new IQuery($queryInfo['name']);
unset($queryInfo['name']);
foreach ($queryInfo as $key => $val) {
$tableObj->{$key} = $val;
}
//存在分頁
if (isset($queryInfo['page']) && $queryInfo['page']) {
return $tableObj;
} else {
$dataResult = $tableObj->find();
if (isset($queryInfo['type']) && $queryInfo['type'] == 'row' && $dataResult) {
$dataResult = current($dataResult);
}
return $dataResult;
}
}
示例13: member_filter
//.........這裏部分代碼省略.........
$and = ' and ';
$where = 'm.status="1"' . $and;
$group_key = IFilter::string(IReq::get('group_key'));
$group_v = IFilter::act(IReq::get('group_value'), 'int');
if ($group_key && $group_v) {
if ($group_key == 'eq') {
$where .= "m.group_id='{$group_v}' {$and}";
} else {
$where .= "m.group_id!='{$group_v}' {$and} ";
}
}
$username_key = IFilter::string(IReq::get('username_key'));
$username_v = IFilter::act(IReq::get('username_value'), 'string');
if ($username_key && $username_v) {
if ($username_key == 'eq') {
$where .= "u.username='{$username_v}' {$and}";
} else {
$where .= 'u.username like "%' . $username_v . '%"' . $and;
}
}
$truename_key = IFilter::string(IReq::get('truename_key'));
$truename_v = IFilter::act(IReq::get('truename_value'), 'string');
if ($truename_key && $truename_v) {
if ($truename_key == 'eq') {
$where .= "m.true_name='{$truename_v}' {$and}";
} else {
$where .= 'm.true_name like "%' . $truename_v . '%"' . $and;
}
}
$mobile_key = IFilter::string(IReq::get('mobile_key'));
$mobile_v = IFilter::act(IReq::get('mobile_value'), 'string');
if ($mobile_key && $mobile_v) {
if ($mobile_key == 'eq') {
$where .= "m.mobile='{$mobile_v}' {$and} ";
} else {
$where .= 'm.mobile like "%' . $mobile_v . '%"' . $and;
}
}
$telephone_key = IFilter::string(IReq::get('telephone_key'));
$telephone_v = IFilter::act(IReq::get('telephone_value'), 'string');
if ($telephone_key && $telephone_v) {
if ($telephone_key == 'eq') {
$where .= "m.telephone='{$telephone_v}' {$and} ";
} else {
$where .= 'm.telephone like "%' . $telephone_v . '%"' . $and;
}
}
$email_key = IFilter::string(IReq::get('email_key'));
$email_v = IFilter::act(IReq::get('email_value'), 'string');
if ($email_key && $email_v) {
if ($email_key == 'eq') {
$where .= "u.email='{$email_v}' {$and} ";
} else {
$where .= 'u.email like "%' . $email_v . '%"' . $and;
}
}
$zip_key = IFilter::string(IReq::get('zip_key'));
$zip_v = IFilter::act(IReq::get('zip_value'), 'string');
if ($zip_key && $zip_v) {
if ($zip_key == 'eq') {
$where .= "m.zip='{$zip_v}' {$and} ";
} else {
$where .= 'm.zip like "%' . $zip_v . '%"' . $and;
}
}
$sex = intval(IReq::get('sex'));
if ($sex && $sex != '-1') {
$where .= 'm.sex=' . $sex . $and;
}
$point_key = IFilter::string(IReq::get('point_key'));
$point_v = intval(IReq::get('point_value'));
if ($point_key && $point_v) {
if ($point_key == 'eq') {
$where .= 'm.point= "' . $point_v . '"' . $and;
} elseif ($point_key == 'gt') {
$where .= 'm.point > "' . $point_v . '"' . $and;
} else {
$where .= 'm.point < "' . $point_v . '"' . $and;
}
}
$regtimeBegin = IFilter::string(IReq::get('regtimeBegin'));
if ($regtimeBegin) {
$where .= 'm.time > "' . $regtimeBegin . '"' . $and;
}
$regtimeEnd = IFilter::string(IReq::get('regtimeEnd'));
if ($regtimeEnd) {
$where .= 'm.time < "' . $regtimeEnd . '"' . $and;
}
$where .= ' 1 ';
$query = new IQuery("member as m");
$query->join = "left join user as u on m.user_id = u.id left join user_group as gp on m.group_id = gp.id";
$query->fields = "m.*,u.username,u.email,gp.group_name";
$query->where = $where;
$query->page = $page;
$query->pagesize = "20";
$this->data['member_list'] = $query->find();
$this->data['pageBar'] = $query->getPageBar('/member/member_filter/');
$this->setRenderData($this->data);
$this->redirect('member_filter');
}
示例14: help_list
function help_list()
{
$query = new IQuery("help AS help");
$query->join = "LEFT JOIN help_category AS cat ON help.cat_id=cat.id";
if (IReq::get('cat_id') !== null) {
$query->where = "help.cat_id = " . intval(IReq::get('cat_id'));
}
$query->fields = "help.*,cat.name AS cat_name";
$query->order = "help.`sort` ASC,help.id DESC";
$query->page = isset($_GET['page']) ? $_GET['page'] : 1;
$this->query = $query;
$this->list = $query->find();
$this->redirect("help_list");
}
示例15: find
/**
* @brief 商品檢索,可以直接讀取 $_GET 全局變量:attr,order,brand,min_price,max_price
* 在檢索商品過程中計算商品結果中的進一步屬性和規格的篩選
* @param mixed $defaultWhere string(條件) or array('search' => '模糊查找','category_extend' => '商品分類ID','字段' => 對應數據)
* @param int $limit 讀取數量
* @param bool $isCondition 是否篩選出商品的屬性,價格等數據
* @return IQuery
*/
public static function find($defaultWhere = '', $limit = 21, $isCondition = true)
{
//獲取配置信息
$siteConfigObj = new Config("site_config");
$site_config = $siteConfigObj->getInfo();
$orderArray = array();
//排序
//開始查詢
$goodsObj = new IQuery("goods as go");
$goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$goodsObj->fields = ' go.* ';
$goodsObj->pagesize = $limit;
/*where條件拚接*/
//(1),當前產品分類
$where = ' go.is_del = 0 ';
//(2),商品屬性,規格篩選
$attrCond = array();
$childSql = '';
$attrArray = IReq::get('attr') ? IFilter::act(IReq::get('attr')) : array();
foreach ($attrArray as $key => $val) {
if ($key && $val) {
$attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",attribute_value)';
}
}
//合並規格與屬性的值,並且生成SQL查詢語句
$GoodsId = null;
if ($attrCond) {
$tempArray = array();
foreach ($attrCond as $key => $cond) {
$tempArray[] = '(' . $cond . ')';
}
$childSql = join(' or ', $tempArray);
$goodsAttrObj = new IQuery('goods_attribute');
$goodsAttrObj->fields = 'goods_id';
$goodsAttrObj->where = $childSql;
$goodsAttrObj->group = 'goods_id';
$goodsAttrObj->having = 'count(goods_id) >= ' . count($attrCond);
//每個子條件都有一條記錄,則存在幾個count(條件)必須包含count(goods_id)條數量
$goodsIdArray = $goodsAttrObj->find();
$goodsIds = array();
foreach ($goodsIdArray as $key => $val) {
$goodsIds[] = $val['goods_id'];
}
$GoodsId = $GoodsId === null ? array_unique($goodsIds) : array_unique(array_intersect($goodsIds, $GoodsId));
}
//(3),處理defaultWhere條件 goods, category_extend
if ($defaultWhere) {
//兼容array 和 string 數據類型的goods條件篩選
$goodsCondArray = array();
if (is_string($defaultWhere)) {
$goodsCondArray[] = $defaultWhere;
} else {
if (is_array($defaultWhere)) {
foreach ($defaultWhere as $key => $val) {
if (!$val) {
continue;
}
//商品分類檢索
if ($key == 'category_extend') {
$currentCatGoods = array();
$categoryExtendObj = new IModel('category_extend');
$categoryExtendList = $categoryExtendObj->query("category_id in (" . $val . ")", 'goods_id', 'id', 'desc');
foreach ($categoryExtendList as $key => $val) {
$currentCatGoods[] = $val['goods_id'];
}
$GoodsId = $GoodsId === null ? array_unique($currentCatGoods) : array_unique(array_intersect($currentCatGoods, $GoodsId));
} else {
if ($key == 'search') {
$wordWhere = array();
$wordLikeOrder = array();
//檢查輸入的內容是否為分詞形式
if (preg_match("#\\s+#", $defaultWhere['search']) == false) {
$wordWhere[] = ' name like "%' . $defaultWhere['search'] . '%" or find_in_set("' . $defaultWhere['search'] . '",search_words) ';
$wordLikeOrder[] = $defaultWhere['search'];
}
//進行分詞
if (IString::getStrLen($defaultWhere['search']) >= 4 || IString::getStrLen($defaultWhere['search']) <= 100) {
$wordData = words_facade::run($defaultWhere['search']);
if (isset($wordData['data']) && count($wordData['data']) >= 2) {
foreach ($wordData['data'] as $word) {
$wordWhere[] = ' name like "%' . $word . '%" ';
$wordLikeOrder[] = $word;
}
}
}
//分詞排序
if (count($wordLikeOrder) > 1) {
$orderTempArray = array();
foreach ($wordLikeOrder as $key => $val) {
$orderTempArray[] = "(CASE WHEN name LIKE '%" . $val . "%' THEN " . $key . " ELSE 100 END)";
}
$orderArray[] = " (" . join('+', $orderTempArray) . ") asc ";
//.........這裏部分代碼省略.........