本文整理匯總了PHP中IQuery::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP IQuery::find方法的具體用法?PHP IQuery::find怎麽用?PHP IQuery::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IQuery
的用法示例。
在下文中一共展示了IQuery::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
/**
* @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: 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];
}
示例3: 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;
}
示例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: IQuery
/**
* @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: goodsCount
/**
* @brief 計算商品價格
* @param Array $buyInfo ,購物車格式
* @return array or bool
*/
public function goodsCount($buyInfo)
{
$this->sum = 0;
//原始總額(優惠前)
$this->final_sum = 0;
//應付總額(優惠後)
$this->weight = 0;
//總重量
$this->reduce = 0;
//減少總額
$this->count = 0;
//總數量
$this->promotion = array();
//促銷活動規則文本
$this->proReduce = 0;
//促銷活動規則優惠額
$this->point = 0;
//增加積分
$this->exp = 0;
//增加經驗
$this->isFreeFreight = false;
//是否免運費
$user_id = $this->user_id;
$group_id = $this->group_id;
$goodsList = array();
$productList = array();
/*開始計算goods和product的優惠信息 , 會根據條件分析出執行以下哪一種情況:
*(1)查看此商品(貨品)是否已經根據不同會員組設定了優惠價格;
*(2)當前用戶是否屬於某個用戶組中的成員,並且此用戶組享受折扣率;
*(3)優惠價等於商品(貨品)原價;
*/
//獲取商品或貨品數據
/*Goods 拚裝商品優惠價的數據*/
if (isset($buyInfo['goods']['id']) && $buyInfo['goods']['id']) {
//購物車中的商品數據
$goodsIdStr = join(',', $buyInfo['goods']['id']);
$goodsObj = new IModel('goods as go');
$goodsList = $goodsObj->query('go.id in (' . $goodsIdStr . ')', 'go.name,go.id as goods_id,go.img,go.sell_price,go.point,go.weight,go.store_nums,go.exp,go.goods_no,0 as product_id');
//開始優惠情況判斷
foreach ($goodsList as $key => $val) {
//檢查庫存
if ($buyInfo['goods']['data'][$val['goods_id']]['count'] <= 0 || $buyInfo['goods']['data'][$val['goods_id']]['count'] > $val['store_nums']) {
return "商品:" . $val['name'] . "購買數量超出庫存,請重新調整購買數量";
}
$groupPrice = $this->getGroupPrice($val['goods_id'], 'goods');
$goodsList[$key]['reduce'] = $groupPrice === null ? 0 : $val['sell_price'] - $groupPrice;
$goodsList[$key]['count'] = $buyInfo['goods']['data'][$val['goods_id']]['count'];
$current_sum_all = $goodsList[$key]['sell_price'] * $goodsList[$key]['count'];
$current_reduce_all = $goodsList[$key]['reduce'] * $goodsList[$key]['count'];
$goodsList[$key]['sum'] = $current_sum_all - $current_reduce_all;
//全局統計
$this->weight += $val['weight'] * $goodsList[$key]['count'];
$this->point += $val['point'] * $goodsList[$key]['count'];
$this->exp += $val['exp'] * $goodsList[$key]['count'];
$this->sum += $current_sum_all;
$this->reduce += $current_reduce_all;
$this->count += $goodsList[$key]['count'];
}
}
/*Product 拚裝商品優惠價的數據*/
if (isset($buyInfo['product']['id']) && $buyInfo['product']['id']) {
//購物車中的貨品數據
$productIdStr = join(',', $buyInfo['product']['id']);
$productObj = new IQuery('products as pro,goods as go');
$productObj->where = 'pro.id in (' . $productIdStr . ') and go.id = pro.goods_id';
$productObj->fields = 'pro.sell_price,pro.weight,pro.id as product_id,pro.spec_array,pro.goods_id,pro.store_nums,pro.products_no as goods_no,go.name,go.point,go.exp,go.img';
$productList = $productObj->find();
//開始優惠情況判斷
foreach ($productList as $key => $val) {
//檢查庫存
if ($buyInfo['product']['data'][$val['product_id']]['count'] <= 0 || $buyInfo['product']['data'][$val['product_id']]['count'] > $val['store_nums']) {
return "貨品:" . $val['name'] . "購買數量超出庫存,請重新調整購買數量";
}
$groupPrice = $this->getGroupPrice($val['product_id'], 'product');
$productList[$key]['reduce'] = $groupPrice === null ? 0 : $val['sell_price'] - $groupPrice;
$productList[$key]['count'] = $buyInfo['product']['data'][$val['product_id']]['count'];
$current_sum_all = $productList[$key]['sell_price'] * $productList[$key]['count'];
$current_reduce_all = $productList[$key]['reduce'] * $productList[$key]['count'];
$productList[$key]['sum'] = $current_sum_all - $current_reduce_all;
//全局統計
$this->weight += $val['weight'] * $productList[$key]['count'];
$this->point += $val['point'] * $productList[$key]['count'];
$this->exp += $val['exp'] * $productList[$key]['count'];
$this->sum += $current_sum_all;
$this->reduce += $current_reduce_all;
$this->count += $productList[$key]['count'];
}
}
$final_sum = $this->sum - $this->reduce;
//總金額滿足的促銷規則
if ($user_id) {
$proObj = new ProRule($final_sum);
$proObj->setUserGroup($group_id);
$this->isFreeFreight = $proObj->isFreeFreight();
$this->promotion = $proObj->getInfo();
//.........這裏部分代碼省略.........
示例10: IQuery
static function get_order_pri_num_del($ogid)
{
$total = 0;
$goods_id = '';
$p_id = '';
$number = '';
//先根據ogid查詢出order_goods單價和數量,然後從order表總價格中刪除
$query = new IQuery('order_goods');
$query->where = 'id = ' . $ogid;
$order_goods_info = $query->find();
if (count($order_goods_info) > 0) {
$order_id = $order_goods_info[0]['order_id'];
$goods_price = $order_goods_info[0]['goods_price'];
$real_price = $order_goods_info[0]['real_price'];
$goods_nums = $order_goods_info[0]['goods_nums'];
$number = $goods_nums;
$goods_id = $order_goods_info[0]['goods_id'];
$p_id = $order_goods_info[0]['product_id'];
$tb_order = new IModel('order');
$tb_order->setData(array('payable_amount' => 'payable_amount-' . $goods_price * $goods_nums, 'real_amount' => 'real_amount-' . $real_price * $goods_nums, 'order_amount' => 'order_amount-' . $real_price * $goods_nums));
$arr = array('payable_amount', 'real_amount', 'order_amount');
$tb_order->update('id=' . $order_id, $arr);
}
$islog = 0;
$tb_order_goods = new IModel('order_goods');
if ($tb_order_goods->del('id=' . $ogid)) {
$islog = 1;
}
//修改goods表中數量,獲得goods表的對象
$tb_goods = new IModel('goods');
$tb_goods->setData(array('store_nums' => 'store_nums+' . $number));
$grr = array('store_nums');
$tb_goods->update('id=' . $goods_id, $grr);
//判斷p_id是否有值如果有則修改products中的數量
if ($p_id != 0) {
$tb_products = new IModel('products');
$tb_products->setData(array('store_nums' => 'store_nums+' . $number));
$prr = array('store_nums');
$tb_products->update('id=' . $p_id, $prr);
}
return $islog;
}
示例11: refundsCount
/**
* @brief 統計退款申請的數量
* @param int $seller_id
*/
public static function refundsCount($seller_id = '')
{
$refundDB = new IQuery('refundment_doc');
$where = 'pay_status = 0 and if_del = 0';
if ($seller_id) {
$where .= ' and seller_id = ' . $seller_id;
}
$refundDB->where = $where;
$refundDB->fields = 'count(*) as num';
$data = $refundDB->find();
return $data[0]['num'];
}
示例12: 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;
}
示例13: goods_report
public function goods_report()
{
//搜索條件
$search = IFilter::act(IReq::get('search'), 'strict');
//條件篩選處理
list($join, $where) = goods_class::getSearchCondition($search);
//拚接sql
$goodsHandle = new IQuery('goods as go');
$goodsHandle->order = "go.sort asc,go.id desc";
$goodsHandle->distinct = "go.id";
$goodsHandle->fields = "go.id, go.name,go.sell_price,go.store_nums,go.sale,go.is_del,go.create_time,seller.true_name";
$goodsHandle->join = $join;
$goodsHandle->where = $where;
$goodsHandle->limit = 'all';
$goodsList = $goodsHandle->find();
//構建 Excel table;
$strTable = '<table width="500" border="1">';
$strTable .= '<tr>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="*">商品名稱</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="160">分類</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">售價</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">庫存</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">銷量</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">發布時間</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">狀態</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="60">隸屬商戶</td>';
$strTable .= '</tr>';
foreach ($goodsList as $k => $val) {
$strTable .= '<tr>';
$strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['name'] . '</td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . goods_class::getGoodsCategory($val['id']) . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . $val['sell_price'] . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . $val['store_nums'] . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . $val['sale'] . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . $val['create_time'] . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . goods_class::statusText($val['is_del']) . ' </td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . $val['true_name'] . ' </td>';
$strTable .= '</tr>';
}
$strTable .= '</table>';
unset($goodsList);
$reportObj = new report();
$reportObj->setFileName('goods');
$reportObj->toDownload($strTable);
exit;
}
示例14: 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 ";
//.........這裏部分代碼省略.........
示例15: isset
</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]);
}
<?php