本文整理汇总了PHP中IModel::query方法的典型用法代码示例。如果您正苦于以下问题:PHP IModel::query方法的具体用法?PHP IModel::query怎么用?PHP IModel::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModel
的用法示例。
在下文中一共展示了IModel::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDelivery
/**
* @param $province string 省份的id
* @param $weight int 货物的重量
* @param $goodsSum float 商品总价格
* @return array()
* @brief 配送方式计算管理模块
*/
public static function getDelivery($province, $weight = 0, $goodsSum = 0)
{
$data = array();
//获得配送方式表的对象
$delivery = new IModel('delivery');
//获取配送方式列表
$where = 'is_delete = 0 and status = 1';
$list = $delivery->query($where, '*', 'sort', 'asc');
//循环各个配送方式
foreach ($list as $value) {
//设置首重和次重
self::$firstWeight = $value['first_weight'];
self::$secondWeight = $value['second_weight'];
$data[$value['id']]['id'] = $value['id'];
$data[$value['id']]['name'] = $value['name'];
$data[$value['id']]['type'] = $value['type'];
$data[$value['id']]['description'] = $value['description'];
$data[$value['id']]['if_delivery'] = '0';
//当配送方式是统一配置的时候,不进行区分地区价格
if ($value['price_type'] == 0) {
$data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
} else {
$matchKey = '';
$flag = false;
//每项都是以';'隔开的省份ID
$area_groupid = unserialize($value['area_groupid']);
foreach ($area_groupid as $key => $result) {
//匹配到了特殊的省份运费价格
if (strpos($result, ';' . $province . ';') !== false) {
$matchKey = $key;
$flag = true;
break;
}
}
//匹配到了特殊的省份运费价格
if ($flag) {
//获取当前省份特殊的运费价格
$firstprice = unserialize($value['firstprice']);
$secondprice = unserialize($value['secondprice']);
$data[$value['id']]['price'] = self::getFeeByWeight($weight, $firstprice[$matchKey], $secondprice[$matchKey]);
} else {
//判断是否设置默认费用了
if ($value['open_default'] == 1) {
$data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
} else {
$data[$value['id']]['price'] = '0';
$data[$value['id']]['if_delivery'] = '1';
}
}
}
//计算保价
if ($value['is_save_price'] == 1) {
$tempProtectPrice = $goodsSum * ($value['save_rate'] * 0.01);
$data[$value['id']]['protect_price'] = $tempProtectPrice <= $value['low_price'] ? $value['low_price'] : $tempProtectPrice;
} else {
$data[$value['id']]['protect_price'] = 0;
}
}
return $data;
}
示例2: area_child
/**
* @brief 获取地区
*/
public function area_child()
{
$parent_id = intval(IReq::get("aid"));
$areaDB = new IModel('areas');
$data = $areaDB->query("parent_id={$parent_id}", '*', 'sort', 'asc');
echo JSON::encode($data);
}
示例3: ucenter_order
public static function ucenter_order()
{
$siteConfig = new Config('site_config');
$order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7;
$order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20;
$orderModel = new IModel('order');
$orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array();
$orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array();
$resultData = array_merge($orderCreateData, $orderCancelData);
if ($resultData) {
foreach ($resultData as $key => $val) {
$type = $val['type_data'];
$order_id = $val['id'];
$order_no = $val['order_no'];
//oerder表的对象
$tb_order = new IModel('order');
$tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime()));
$tb_order->update('id=' . $order_id);
//生成订单日志
$tb_order_log = new IModel('order_log');
//订单自动完成
if ($type == '5') {
$action = '完成';
$note = '订单【' . $order_no . '】完成成功';
//完成订单并且进行支付
Order_Class::updateOrderStatus($order_no);
//增加用户评论商品机会
Order_Class::addGoodsCommentChange($order_id);
$logObj = new log('db');
$logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no));
} else {
$action = '作废';
$note = '订单【' . $order_no . '】作废成功';
//订单重置取消
Order_class::resetOrderProp($order_id);
$logObj = new log('db');
$logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no));
}
$tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime()));
$tb_order_log->add();
}
}
}
示例4: get_mess_ids
/**
* @param $user_id string 用户的id
* @return $message String 返回站内消息id的字符串
* @brief 获得member表中的messageid,去掉-的message的id
*/
public function get_mess_ids()
{
$tb_member = new IModel('member');
$member_info = $tb_member->query('user_id=' . $this->user_id);
$message = null;
$this->old_ids = $member_info[0]['message_ids'];
if (count($member_info) > 0) {
$message = str_replace('-', '', $member_info[0]['message_ids']);
}
return $message;
}
示例5: name
/**
* @brief 根据传入的地域ID获取地域名称,获取的名称是根据ID依次获取的
* @param int 地域ID 匿名参数可以多个id
* @return array
*/
public static function name()
{
$result = array();
$paramArray = func_get_args();
$areaDB = new IModel('areas');
$areaData = $areaDB->query("area_id in (" . trim(join(',', $paramArray), ",") . ")");
foreach ($areaData as $key => $value) {
$result[$value['area_id']] = $value['area_name'];
}
return $result;
}
示例6: init
function init()
{
$this->tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
// 获取导航配置
$guideObj = new IModel('guide');
$guide_list = $guideObj->query('', '`order`,`name`,`link`', '`order`', 'desc');
if (count($guide_list) > 0) {
$this->guide_list = $guide_list;
}
$this->sort_type_map = array('0' => "{$this->tablePre}goods.sort ASC", '1' => "{$this->tablePre}goods.volume DESC", '2' => "{$this->tablePre}goods.discount ASC");
$siteConfigObj = new Config("site_config");
$site_config = $siteConfigObj->getInfo();
$this->site_config = $site_config;
}
示例7: get_cat_by_id
public static function get_cat_by_id($id)
{
if (!is_array($id)) {
$id = array($id);
}
if (!$id) {
return array();
}
foreach ($id as $key => $value) {
$id[$key] = intval($value);
}
$id = implode(",", array_unique($id));
$tb_help_cat = new IModel('help_category');
$list = $tb_help_cat->query("id IN ({$id})");
return Util::array_rekey($list, 'id');
}
示例8: IModel
/**
* @brief 品牌分类添加、修改
*/
function category_edit()
{
$category_id = (int) IReq::get('cid');
//编辑品牌分类 读取品牌分类信息
if ($category_id) {
$obj_brand_category = new IModel('brand_category');
$category_info = $obj_brand_category->query('id=' . $category_id);
if (is_array($category_info) && ($info = $category_info[0])) {
$this->data['category'] = array('id' => $info['id'], 'name' => $info['name']);
} else {
$this->category_list();
Util::showMessage("没有找到相关品牌分类!");
return;
}
}
$this->setRenderData($this->data);
$this->redirect('category_edit', false);
}
示例9: unsubscribe
/**
* 退订,并记录退订理由
* @param string $email
* @param string $content 退订理由
* @static
*/
public static function unsubscribe($email, $content)
{
$email = addslashes($email);
$tb = new IModel("email_registry");
$re = $tb->query("email = '{$email}' AND flag=1");
if (!$re) {
return array('flag' => false, 'data' => '你还没有订阅');
}
$re = end($re);
/*
$re['content'] = htmlspecialchars($content,ENT_QUOTES);
$re['flag'] = 0;
$tb->setData($re);
$tb->update("id={$re['id']}");
*/
$tb->del("id={$re['id']}");
return array('flag' => true, 'data' => 'success');
}
示例10: showCat
static function showCat($selectName = 'category_id', $selectedValue = null, $defaultValue = array())
{
//取得文章分类信息
$catObj = new IModel('article_category');
$data = $catObj->query('', 'id,name,path', 'path', 'asc');
$str = '<select class="auto" name="' . $selectName . '" pattern="required" alt="请选择分类值">';
//默认option值
if (!empty($defaultValue)) {
$str .= '<option value="' . current($defaultValue) . '">' . key($defaultValue) . '</option>';
}
//拼接分类信息
foreach ($data as $val) {
$isSelect = $val['id'] == $selectedValue ? 'selected=selected' : null;
$str .= '<option value="' . $val['id'] . '" ' . $isSelect . '>' . str_repeat(" ", substr_count($val['path'], ",") - 2) . '└' . $val['name'] . '</option>';
}
$str .= '</select>';
return $str;
}
示例11: IModel
/**
* @brief 修改品牌
*/
function brand_edit()
{
$brand_id = (int) IReq::get('bid');
//编辑品牌 读取品牌信息
if ($brand_id) {
$obj_brand = new IModel('brand');
$brand_info = $obj_brand->query('id=' . $brand_id);
if (is_array($brand_info) && ($info = $brand_info[0])) {
$this->data['brand'] = array('id' => $info['id'], 'name' => $info['name'], 'logo' => $info['logo'], 'url' => $info['url'], 'sort' => $info['sort'], 'description' => $info['description']);
} else {
$this->category_list();
Util::showMessage("没有找到相关品牌分类!");
return;
}
}
$this->setRenderData($this->data);
$this->redirect('brand_edit', false);
}
示例12: can_comment
/**
* 检测用户是否能够评论
*
* @param int $comment_id 评论id
* @param int $user_id 用户id
* @return array() array(成功or失败,数据)
*/
public static function can_comment($comment_id, $user_id)
{
$comment_id = intval($comment_id);
$user_id = intval($user_id);
$tb_comment = new IModel("comment");
$comment = $tb_comment->query("id={$comment_id} AND user_id={$user_id}");
if (!$comment) {
return array(-1, "没有这条数据");
}
$comment = end($comment);
if ($comment['status'] != 0) {
return array(-2, $comment);
}
$time = strtotime($comment['time']);
if ($time < 3600 * 24 * 30 * 6) {
return array(-3, $comment);
}
return array(1, $comment);
}
示例13: IModel
function registry_list()
{
$tb_user_group = new IModel('user_group');
$data_group = $tb_user_group->query();
$data_group = is_array($data_group) ? $data_group : array();
$group = array();
foreach ($data_group as $value) {
$group[$value['id']] = $value['group_name'];
}
$this->data['group'] = $group;
$this->setRenderData($this->data);
//获取模板
$tb_tpl = new IModel("msg_template");
$tpl = $tb_tpl->getObj("id=2");
if (!$tpl) {
$tpl = array('name' => '', 'title' => '', 'content' => '');
}
$this->tpl = $tpl;
$this->redirect('registry_list');
}
示例14: 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;
}
示例15: getPaymentListByOnline
public function getPaymentListByOnline()
{
$where = " type = 1 and status = 0 and class_name not in ('balance','offline') ";
switch (IClient::getDevice()) {
//移动支付
case IClient::MOBILE:
$where .= ' and client_type in(2,3) ';
//如果不是微信客户端,去掉微信专用支付
if (IClient::isWechat() == false) {
$where .= " and class_name != 'wap_wechat'";
}
break;
//pc支付
//pc支付
case IClient::PC:
$where .= ' and client_type in(1,3) ';
break;
}
$paymentDB = new IModel('payment');
return $paymentDB->query($where);
}