当前位置: 首页>>代码示例>>PHP>>正文


PHP kernel::database方法代码示例

本文整理汇总了PHP中kernel::database方法的典型用法代码示例。如果您正苦于以下问题:PHP kernel::database方法的具体用法?PHP kernel::database怎么用?PHP kernel::database使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kernel的用法示例。


在下文中一共展示了kernel::database方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: end

 function end($result = true, $message = null, $url_params = null, $params = array())
 {
     if (!$this->transaction_start) {
         trigger_error('The transaction has not started yet', E_USER_ERROR);
     }
     $this->transaction_start = false;
     $db = kernel::database();
     restore_error_handler();
     if (is_null($url_params)) {
         $url = $this->_action_url;
     } elseif (is_array($url_params)) {
         $url = $this->app->router()->gen_url($url_params);
     } else {
         $url = $url_params;
     }
     if ($result) {
         $db->commit($this->transaction_status);
         $status = 'success';
         $message = $message == '' ? app::get('base')->_('操作成功!') : app::get('base')->_('成功:') . $message;
     } else {
         $db->rollback();
         $status = 'error';
         $message = $message ? $message : app::get('base')->_("操作失败: 对不起,无法执行您要求的操作");
     }
     $this->_end_message = $message;
     $this->splash($status, $url, $message, 'redirect', $params);
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:27,代码来源:controller.php

示例2: create

 /**
  * 售后服务单创建
  * @param array sdf
  * @param string message
  * @return boolean success or failure
  */
 public function create(&$sdf, &$thisObj)
 {
     if (!$sdf['order_bn'] || !$sdf['return_bn']) {
         $thisObj->send_user_error(app::get('b2c')->_('售后服务单数据异常!'), array('tid' => $sdf['order_bn'], 'return_id' => $sdf['return_bn']));
     } else {
         $is_save = true;
         $obj_return_product = $this->app->model('return_product');
         $return_id = $obj_return_product->gen_id();
         $arr_product_data = json_decode($sdf['return_product_items'], true);
         $str_product_data = serialize($arr_product_data);
         $tmp = $obj_return_product->getList('*', array('return_bn' => $sdf['return_bn'], 'order_id' => $sdf['order_bn']));
         if ($tmp) {
             $thisObj->send_user_error(app::get('b2c')->_('售后服务单已经存在!'), array('tid' => $sdf['order_bn'], 'return_id' => $sdf['return_bn']));
         }
         // 开始事务
         $db = kernel::database();
         $transaction_status = $db->beginTransaction();
         $arr_data = array('order_id' => $sdf['order_bn'], 'return_bn' => $sdf['return_bn'], 'return_id' => $return_id, 'title' => $sdf['title'], 'content' => $sdf['content'], 'comment' => $sdf['comment'], 'status' => $sdf['status'], 'product_data' => $str_product_data, 'member_id' => $sdf['member_id'], 'add_time' => $sdf['add_time']);
         if ($sdf['url'] && strpos($sdf['url'], '/') !== false) {
             $mdl_img = app::get('image')->model('image');
             $image_name = substr($sdf['url'], strrpos($sdf['url'], '/') + 1);
             $image_id = $mdl_img->store($sdf['url'], null, null, $image_name);
             $arr_data['image_file'] = $image_id;
         }
         $is_save = $obj_return_product->save($arr_data);
         if ($is_save) {
             $db->commit($transaction_status);
             return array('tid' => $sdf['order_bn'], 'return_id' => $sdf['return_bn']);
         } else {
             $db->rollback();
             $thisObj->send_user_error(app::get('b2c')->_('售后服务单添加失败!'), array('tid' => $sdf['order_bn'], 'return_id' => $sdf['return_bn']));
         }
     }
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:40,代码来源:aftersale.php

示例3: get_pager

 private function get_pager($page_no, $page_size, $sTableName, $sWhere = '')
 {
     $page_no = intval($page_no);
     $page_size = intval($page_size);
     $limit = '';
     $rs_count = 0;
     $sql = 'select count(*) as c from `' . $sTableName . '` ' . $sWhere;
     //-------------------------------------------------
     $db = kernel::database();
     $rs = $db->selectrow($sql);
     if ($rs && is_array($rs)) {
         $rs_count = intval($rs['c']);
     }
     $str_limit = '';
     $offset = 0;
     $limit = -1;
     $page_count = 0;
     if ($rs_count > 0) {
         $page_count = ceil($rs_count / $page_size);
         if ($page_no < 1) {
             $page_no = 1;
         } else {
             if ($page_no > $page_count) {
                 $page_no = $page_count;
             }
         }
         $offset = ($page_no - 1) * $page_size;
         $limit = $page_size;
         $str_limit = ' LIMIT ' . $offset . ',' . $limit;
     } else {
         $page_no = 1;
     }
     return array('rs_count' => $rs_count, 'page_count' => $page_count, 'page_no' => $page_no, 'page_size' => $page_size, 'offset' => $offset, 'limit' => $limit, 'str_limit' => $str_limit);
 }
开发者ID:noikiy,项目名称:Ecstore-to-odoo,代码行数:34,代码来源:advance.php

示例4: create

 /**
  * 退款单创建
  * @param array sdf
  * @return boolean success or failure
  */
 public function create(&$sdf, $thisObj)
 {
     // 退款单创建是和中心的交互
     $is_payed = false;
     $obj_refund = $this->app->model('refunds');
     $obj_order = $this->app_b2c->model('orders');
     $objMath = kernel::single('ectools_math');
     if (!isset($sdf['order_bn']) || !$sdf['order_bn']) {
         $thisObj->send_user_error(app::get('b2c')->_('退款单tid没有收到!'), array());
     }
     $obj_order_bills = $this->app->model('order_bills');
     $sql = 'SELECT * FROM ' . $obj_refund->table_name(1) . ' AS refunds' . ' LEFT JOIN ' . $obj_order_bills->table_name(1) . ' AS bill ON bill.bill_id=refunds.refund_id' . ' WHERE refunds.t_begin=' . $sdf['t_begin'] . ' AND bill.bill_type="refunds" AND bill.rel_id=\'' . $sdf['order_bn'] . '\'';
     if (!$obj_order_bills->db->select($sql)) {
         $refund_id = $sdf['refund_id'] = $obj_refund->gen_id();
         $refundArr = array('refund_id' => $sdf['refund_id'], 'refund_bn' => $sdf['refund_bn'], 'order_id' => $sdf['order_bn'], 'account' => $sdf['account'], 'bank' => $sdf['bank'], 'pay_account' => $sdf['pay_account'] ? $sdf['pay_account'] : app::get('b2c')->_('付款帐号'), 'currency' => $sdf['currency'], 'money' => $sdf['money'], 'paycost' => $sdf['paycost'], 'cur_money' => $sdf['cur_money'], 'pay_type' => $sdf['pay_type'], 'pay_app_id' => $sdf['payment_tid'], 'pay_name' => $sdf['pay_name'], 'pay_ver' => '1.0', 'op_id' => '0', 'ip' => $sdf['ip'], 't_begin' => $sdf['t_begin'], 't_payed' => $sdf['t_begin'], 't_confirm' => $sdf['t_confirm'], 'status' => 'ready', 'trade_no' => $sdf['trade_no'], 'memo' => $sdf['memo'], 'return_url' => '', 'orders' => array(array('rel_id' => $sdf['order_bn'], 'bill_type' => 'refunds', 'pay_object' => 'order', 'bill_id' => $sdf['refund_id'], 'money' => $sdf['money'])));
         $is_save = $obj_refund->save($refundArr);
     } else {
         $sdf['refund_id'] = $refund_id = $tmp[0]['bill_id'];
     }
     // 更改支付单状态
     $filter = array('refund_id' => $refund_id, 'status|in' => array('failed', 'cancel', 'error', 'invalid', 'timeout', 'ready'));
     $is_save = $obj_refund->update(array('status' => 'succ'), $filter);
     $affect_row = $obj_refund->db->affect_row();
     if ($is_save) {
         $db = kernel::database();
         $transaction_status = $db->beginTransaction();
         // 防止重复充值
         if ($affect_row) {
             $tmp_refunds = $obj_refund->getList('*', array('refund_id' => $refund_id));
             if (!$tmp_refunds) {
                 $thisObj->send_user_error(app::get('b2c')->_('退款单不存在!'), array('tid' => $sdf['order_bn'], 'refund_id' => $refund_id));
             }
             $refundArr = $tmp_refunds[0];
             $refundArr['order_id'] = $sdf['order_bn'];
             // 修改订单状态.
             $refundArr['op_name'] = 'ome' . app::get('b2c')->_('管理员');
             $refundArr['payment'] = $refundArr['pay_app_id'];
             $obj_refund_finish = kernel::single('b2c_order_refund');
             $is_payed = $obj_refund_finish->order_refund_finish($refundArr, 'succ', 'font', $msg);
         } else {
             $db->rollback();
             $filter = array('refund_id' => $refund_id);
             $obj_refund->update(array('status' => 'failed'), $filter);
             $thisObj->send_user_error(app::get('b2c')->_('退款多次重复请求!'), array('tid' => $sdf['order_bn'], 'refund_id' => $sdf['refund_id']));
         }
     }
     if (!$is_save || !$is_payed) {
         $db->rollback();
         $msg = $msg ? $msg : app::get('b2c')->_('退款单生成失败!');
         $filter = array('refund_id' => $refund_id);
         $obj_refund->update(array('status' => 'failed'), $filter);
         $thisObj->send_user_error($msg, array('tid' => $sdf['order_bn'], 'refund_id' => $sdf['refund_id']));
     }
     $db->commit($transaction_status);
     $obj_refund_finish->send_request($refundArr);
     $obj_apiv = kernel::single('b2c_apiv_exchanges_request');
     $req_arr = array('order_id' => $sdf['order_bn']);
     $obj_apiv->rpc_caller_request($req_arr, 'orderupdate');
     return array('tid' => $sdf['order_bn'], 'refund_id' => $sdf['refund_id']);
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:65,代码来源:refund.php

示例5: getTreeList

function getTreeList($pid = 0, $listMark = 'all')
{
    $var_pid = $pid;
    $var_listMark = $listMark;
    $a = kernel::database();
    if ($listMark == 'all') {
        $aCat = $a->select('SELECT cat_name,cat_id,o.parent_id AS pid,o.p_order,o.cat_path,o.is_leaf AS cls,o.type_id as type
                    FROM sdb_b2c_goods_cat o WHERE o.disabled=\'false\' ORDER BY o.cat_path,o.p_order,o.cat_id');
        foreach ($aCat as $k => $row) {
            if ($row['cat_path'] != '' && $row['cat_path'] != ',') {
                $aCat[$k]['cat_path'] = substr($row['cat_path'], 1);
            }
        }
    } else {
        if ($pid === 0) {
            $sqlWhere = '(parent_id IS NULL OR parent_id=' . intval($pid) . ')';
        } else {
            $sqlWhere = 'parent_id=' . intval($pid);
        }
        $sqlWhere .= " AND o.disabled='false'";
        $aCat = $a->select('SELECT cat_name, cat_id, o.parent_id AS pid, o.p_order, o.cat_path, o.is_leaf AS cls,o.type_id, t.name AS type_name FROM sdb_b2c_goods_cat o
                    LEFT JOIN sdb_b2c_goods_type t ON o.type_id = t.type_id
                    WHERE ' . $sqlWhere . ' ORDER BY o.cat_path,o.p_order,o.cat_id');
        foreach ($aCat as $k => $row) {
            $aCat[$k]['pid'] = intval($aCat[$k]['pid']);
            if ($row['cat_path'] == '' || $row['cat_path'] == ',') {
                $aCat[$k]['step'] = 1;
            } else {
                $aCat[$k]['step'] = substr_count($row['cat_path'], ',') + 1;
            }
            $aCat[$k]['url'] =& kernel::router()->gen_url(array('app' => 'b2c', 'ctl' => 'gallery', 'act' => $render->app->getConf('gallery.default_view'), 'args' => array($aCat[$k]['cat_id']), null, $app->base_url()));
        }
    }
    return $aCat;
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:35,代码来源:widget_goodscat.php

示例6: offline_point

 public function offline_point($arr, $rpcService)
 {
     $sql = 'SELECT login_account AS mobile, offline_cardno FROM sdb_b2c_members AS bm LEFT JOIN sdb_pam_members as pm ON bm.member_id = pm.member_id WHERE bm.member_id = ' . $this->app->member_id . ' AND login_type =  \'mobile\'';
     $memberData = kernel::database()->select($sql);
     $mobile = $memberData['mobile'];
     /*
     $pamMemberData = app::get('pam')->model('members')->getList('*',array('member_id'=>$this->app->member_id));
     foreach ($pamMemberData as $row) {
         if ($row['login_type'] == 'mobile') {
             $mobile = $row['login_account'];
         }
     }
     */
     //$mobile = '13910510236';
     if ($mobile) {
         $client = new SoapClient("http://202.106.132.100/AppTest/WMAppCommWebService.asmx?wsdl");
         $arrPara = array((object) array('authKey' => '', 'accountNo' => '2-' . $mobile, 'password' => null));
         $result = $client->__Call("SearchMemberCardInfo", $arrPara);
         $xml = kernel::single('site_utility_xml');
         $arrData = $xml->xml2arrayValues($result->SearchMemberCardInfoResult, 0);
         $params = $arrData['OutputResult'];
         if ($params['ResultFlag'] == 1) {
             # 写入卡号到会员
             if ($params['CardNo']) {
                 app::get('b2c')->model('members')->update(array('offline_cardno' => $params['CardNo']), array('member_id' => $this->app->member_id));
             }
             return $params;
         }
     }
     return '手机号码不存在!';
 }
开发者ID:noikiy,项目名称:Ecstore-to-odoo,代码行数:31,代码来源:point.php

示例7: is_delete

 /**
  * 
  * @params $gid 商品id
  * @params $pid 货品id
  * @return bool
  **/
 public function is_delete($gid, $pid = null)
 {
     $filter = array();
     #if( $pid )
     #    $filter['product_id'] = $pid;
     if ($gid) {
         $filter['gid'] = $gid;
     }
     if (!$filter) {
         return true;
     }
     $objProducts = app::get('b2c')->model('products');
     $ret = $objProducts->getList('product_id', array('goods_id' => $gid));
     foreach ($ret as $val) {
         $product_ids[] = $val['product_id'];
     }
     $db = kernel::database();
     $count = $db->select('SELECT pid FROM  `sdb_groupactivity_purchase` where pid in(' . implode(',', $product_ids) . ')');
     //$count = $this->o_purchase->dump( $filter );
     if (count($count)) {
         $this->error_msg = '该商品在团购中存在!无法删除!';
         return false;
     }
     return true;
 }
开发者ID:noikiy,项目名称:Ecstore-to-odoo,代码行数:31,代码来源:check.php

示例8: count

 function count($filter = null)
 {
     $filter['type'] = 'sto';
     $filter['object_type'] = 'goods';
     $row = kernel::database()->select('SELECT count(*) AS _count FROM sdb_b2c_member_goods WHERE ' . $this->_filter($filter));
     return intval($row[0]['_count']);
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:7,代码来源:sto.php

示例9: archive

 public function archive($return_ids)
 {
     $db = kernel::database();
     $transaction_status = $db->beginTransaction();
     $insert_error_code = 0;
     $delete_error_code = 0;
     // 归档数据到新表
     try {
         $this->op_archive($return_ids, false);
     } catch (Exception $e) {
         $insert_error_code = $e->getCode();
     }
     if ($insert_error_code == 30002) {
         $db->rollback();
     } else {
         // 删除老数据
         try {
             $this->op_archive($return_ids, true);
         } catch (Exception $e) {
             $delete_error_code = $e->getCode();
         }
         if ($delete_error_code == 30003) {
             $db->rollback();
         } else {
             $db->commit($transaction_status);
         }
     }
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:28,代码来源:returnProduct.php

示例10: get_sale_num

 public function get_sale_num($filter = null)
 {
     //商品销售总量
     $sql = 'SELECT sum(I.nums) as sale_num FROM ' . kernel::database()->prefix . 'b2c_orders as O LEFT JOIN ' . kernel::database()->prefix . 'b2c_order_items as I ON O.order_id=I.order_id WHERE ' . 'O.disabled="false" and ' . $this->_filter($filter);
     $row = $this->db->select($sql);
     return $row[0]['sale_num'];
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:7,代码来源:shopsale.php

示例11: updateStore

 /**
  * 库存修改
  * @param array sdf
  * @return boolean success of failure
  */
 public function updateStore(&$sdf, $thisObj)
 {
     if (!isset($sdf['list_quantity']) || !$sdf['list_quantity']) {
         $thisObj->send_user_error(app::get('b2c')->_('需要更新的货品的库存不存在!'), array());
     } else {
         $has_error = false;
         $arr_store = json_decode($sdf['list_quantity'], true);
         $product = $this->app->model('products');
         $obj_goods = $this->app->model('goods');
         $fail_products = array();
         $db = kernel::database();
         if (isset($arr_store) && $arr_store) {
             foreach ($arr_store as $arr_product_info) {
                 if ($arr_product_info['bn'] && is_numeric($arr_product_info['quantity'])) {
                     $arr_product = $product->dump(array('bn' => $arr_product_info['bn']));
                     if ($arr_product) {
                         $store_increased = $this->objMath->number_minus(array(floatval($arr_product_info['quantity']), floatval($arr_product['store'])));
                         $arr_goods = $db->selectrow('SELECT store,goods_id from sdb_b2c_goods where goods_id =' . $arr_product['goods_id']);
                         $goods_store = $this->objMath->number_plus(array($arr_goods['store'], $store_increased, $arr_product['freez']));
                         $arr_goods['store'] = $goods_store == '0' ? 0 : $goods_store;
                         $arr_product['store'] = $this->objMath->number_plus(array($arr_product_info['quantity'], $arr_product['freez']));
                         $arr_product['last_modify'] = time();
                         $storage_enable = $this->app->getConf('site.storage.enabled');
                         if (!is_null($arr_product['store']) && $storage_enable != 'true') {
                             $is_save = $product->save($arr_product);
                             if ($is_save) {
                                 $obj_goods->update($arr_goods, array('goods_id' => $arr_goods['goods_id']));
                             }
                         } else {
                             $is_save = true;
                         }
                         if (!$is_save) {
                             $msg = $this->app->_('商品库存更新失败!');
                             $has_error = true;
                             $fail_products[] = $arr_product_info['bn'];
                             continue;
                         }
                     } else {
                         $has_error = true;
                         $fail_products[] = $arr_product_info['bn'];
                         continue;
                     }
                 } else {
                     $has_error = true;
                     continue;
                 }
             }
             if (!$has_error) {
                 return true;
             } else {
                 // 更新部分失败.
                 $fail_products = array('error_response' => $fail_products);
                 $thisObj->send_user_error(app::get('b2c')->_('更新库存部分失败!'), $fail_products);
             }
         } else {
             $thisObj->send_user_error(app::get('b2c')->_('更新的商品的库存信息不存在!'), array());
         }
     }
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:64,代码来源:store.php

示例12: goodslist

    function goodslist($brand_id = 0)
    {
        $sql = 'SELECT * FROM test_goods g 
		LEFT JOIN test_rebate r on g.brand_id = r.rebate_id' . $brand_id == 0 ? '' : 'WHERE g.brand_id =' . $brand_id;
        // $retult = $this->db->select($sql);
        $retult = kernel::database()->select($sql);
        return $retult;
    }
开发者ID:sss201413,项目名称:ecstore,代码行数:8,代码来源:goods.php

示例13: get_mysql_status

 function get_mysql_status()
 {
     $aResult = array('mysql.server_host' => DB_HOST, 'mysql.server_dbname' => DB_NAME, 'mysql.server_user' => DB_USER);
     foreach (kernel::database()->select("show status") as $row) {
         $aResult['mysql.' . strtolower($row["Variable_name"])] = $row["Value"];
     }
     return $aResult;
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:8,代码来源:system.php

示例14: table_name

 function table_name($real = false)
 {
     if ($real) {
         return kernel::database()->prefix . $this->app->app_id . '_app_content';
     } else {
         return 'app_content';
     }
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:8,代码来源:search.php

示例15: __construct

 function __construct()
 {
     $sql = "select * from sdb_dbeav_meta_register";
     $arr_rows = kernel::database()->select($sql);
     foreach ($arr_rows as $row) {
         $this->_meta_columns[$row['tbl_name']][$row['col_name']] = $row;
     }
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:8,代码来源:metadata.php


注:本文中的kernel::database方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。