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


PHP mysql_class::select_one方法代码示例

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


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

示例1: smarty_function_load_data

function smarty_function_load_data($params, &$smarty)
{
    (!isset($params['table']) || empty($params['table'])) && exit('`table` is empty!');
    // $Mconfig = include(hopedir."config/hopeconfig.php");
    // print_r($Mconfig);
    $type = isset($params['type']) ? $params['type'] : 'list';
    //total  总数量   one    list 3个分类
    $fileds = isset($params['fileds']) ? $params['fileds'] : '*';
    $where = isset($params['where']) ? $params['where'] : '';
    $where = empty($where) ? '' : ' where ' . $where;
    $orderby = isset($params['orderby']) ? 'order by ' . $params['orderby'] : '';
    $limit = isset($params['limit']) ? 'LIMIT 0,' . $params['limit'] : 'LIMIT 0,1';
    if (!class_exists('mysql_class')) {
        include hopedir . "lib/core/extend/mysql_class.php";
        //core\extend
        $mysql = new mysql_class();
    } else {
        $mysql = new mysql_class();
    }
    $page = intval(IFilter::act(IReq::get('page')));
    $pagesize = intval(IFilter::act(IReq::get('pagesize')));
    $pagesize = isset($params['pagesize']) ? $params['pagesize'] : $pagesize;
    $pagesize = empty($pagesize) ? 10 : $pagesize;
    // $db = $class::factory(array('table' => $params['table']));
    //var_dump($params);
    if (!empty($params['assign'])) {
        //把数据赋值给变量$params['assign'],这样前端就可以使用这个变量了(例如可以结合foreach输出一个列表等)
        //  $smarty->assign($params['assign'], $db->get_block_list(array($params['where']), $params['limit']));
        if ($type == 'total') {
            $result = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . " " . $limit . "");
        } elseif ($type == 'one') {
            $result = $mysql->select_one("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . " " . $limit . "");
        } else {
            if (isset($params['showpage']) && $params['showpage'] == true) {
                if (!class_exists('page')) {
                    include hopedir . "lib/core/extend/page.php";
                    //core\extend
                    $pageclass = new page();
                } else {
                    $pageclass = new page();
                }
                $pageclass->setpage($page, $pagesize);
                $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . "  " . $orderby . "  limit " . $pageclass->startnum() . ", " . $pageclass->getsize() . "");
                $shuliang = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " ");
                $pageclass->setnum($shuliang);
                if (isset($params['pagetype'])) {
                    $result['pagecontent'] = $pageclass->ajaxbar($params['pagetype']);
                } else {
                    $result['pagecontent'] = $pageclass->getpagebar();
                }
            } else {
                $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . "  " . $limit . "");
            }
        }
        /*
            $result['list'] = array();
             $result['pagecontent'] = ''; */
        $smarty->assign($params['assign'], $result);
    }
}
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:60,代码来源:function.load_data.php

示例2: getGoodInfo

 private function getGoodInfo($gid, $type = 'goods')
 {
     $dataArray = array();
     //    typeid 商品类型 name 商品名称 count 商品数量 cost 商品价格 img 图片地址 point 评分 sellcount 销售数量 shopid 店铺ID uid  signid
     $mysql = new mysql_class();
     $dataArray = $mysql->select_one("select id,name,count as shuliang,cost,img,shopid,sellcount from " . Mysite::$app->config['tablepre'] . "goods where id=" . $gid . "  ");
     $dataArray['id'] = $dataArray['id'];
     return $dataArray;
 }
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:9,代码来源:newcart.php

示例3: dirname

<?php

define('hopedir', dirname(__FILE__) . DIRECTORY_SEPARATOR);
//global
$Mconfig = (include hopedir . "config/hopeconfig.php");
//网站配置
date_default_timezone_set("Asia/Hong_Kong");
//header("Content-Type:text/html;charset=utf-8");
include hopedir . "wx/mysql_class.php";
include hopedir . '/lib/function.php';
logwrite('startsend');
if (array_key_exists('shopid', $_GET)) {
    $mysql = new mysql_class();
    $wx_info = $mysql->select_one("select token from " . $Mconfig['tablepre'] . "shop_wechat where shopid='" . (int) $_GET['shopid'] . "'");
    define("TOKEN", $wx_info['token']);
    define("ISSHOP", (int) $_GET['shopid']);
} else {
    define("TOKEN", $Mconfig['wxtoken']);
    define("ISSHOP", 0);
}
$wechatObj = new wechatCallbackapiTest();
if (isset($_GET['echostr'])) {
    $wechatObj->valid();
} else {
    $wechatObj->responseMsg();
    //
}
class wechatCallbackapiTest
{
    //  private $mysql; //定义数据库
    private $wxback;
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:31,代码来源:wx.php

示例4: cartFormat

 /**
  * @brief  把cookie的结构转化成为程序所用的数据结构
  * @param  $cartValue 购物车cookie存储结构
  * @return array : [goods]=>array( ['id']=>商品ID , ['data'] => array( [商品ID]=>array ([name]商品名称 , [list_img]图片地址 , [sell_price]价格, [count]购物车中此商品的数量 ,[type]类型goods,product , [goods_id]商品ID值 ) ) ) , [product]=>array( 同上 ) , [count]购物车商品和货品数量 , [sum]商品和货品总额 ;
  */
 private function cartFormat($cartValue)
 {
     //初始化结果
     $result = $this->cartExeStruct;
     $goodsIdArray = array();
     $marketIdArray = array();
     if (isset($cartValue['goods']) && $cartValue['goods']) {
         $goodsIdArray = array_keys($cartValue['goods']);
         $result['goods']['id'] = $goodsIdArray;
         foreach ($goodsIdArray as $gid) {
             $result['goods']['data'][$gid] = array('id' => $gid, 'type' => 'goods', 'goods_id' => $gid, 'count' => $cartValue['goods'][$gid]);
             //购物车中的种类数量累加
             $result['count'] += $cartValue['goods'][$gid];
         }
     }
     if (isset($cartValue['market']) && $cartValue['market']) {
         $marketIdArray = array_keys($cartValue['market']);
         $result['market']['id'] = $marketIdArray;
         foreach ($marketIdArray as $gid) {
             $result['market']['data'][$gid] = array('id' => $gid, 'type' => 'market', 'goods_id' => $gid, 'count' => $cartValue['market'][$gid]);
             //购物车中的种类数量累加
             $result['count'] += $cartValue['market'][$gid];
         }
     }
     $mysql = new mysql_class();
     if ($marketIdArray) {
         $marketArray = array();
         $marketData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $marketIdArray) . ")  order by id asc  ");
         foreach ($marketData as $goodsVal) {
             $marketArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($result['market']['data'] as $key => $val) {
             $result['market']['data'][$key]['img'] = $marketArray[$val['goods_id']]['img'];
             $result['market']['data'][$key]['name'] = $marketArray[$val['goods_id']]['name'];
             $result['market']['data'][$key]['cost'] = $marketArray[$val['goods_id']]['cost'];
             $result['market']['data'][$key]['shopid'] = $marketArray[$val['goods_id']]['shopid'];
             $result['market']['data'][$key]['store_num'] = $marketArray[$val['goods_id']]['shuliang'];
             $result['market']['data'][$key]['sellcount'] = $marketArray[$val['goods_id']]['sellcount'];
             $result['market']['shopdata'][$marketArray[$val['goods_id']]['shopid']]['list'][] = $key;
             $sumdo = $marketArray[$val['goods_id']]['cost'] * $val['count'];
             $shopid = $marketArray[$val['goods_id']]['shopid'];
             if (!isset($result['goods']['shopdata'][$shopid]['shopinfo'])) {
                 $result['market']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . $shopid . "' ");
             }
             $result['market']['shopdata'][$shopid]['sum'] = isset($result['market']['shopdata'][$shopid]['sum']) ? $result['market']['shopdata'][$shopid]['sum'] + $sumdo : $sumdo;
             $result['market']['shopdata'][$shopid]['sumcount'] = isset($result['market']['shopdata'][$shopid]['sumcount']) ? $result['market']['shopdata'][$shopid]['sumcount'] + $val['count'] : $val['count'];
             //购物车中的金额累加
             $tempshopids[] = $marketArray[$val['goods_id']]['shopid'];
             //echo '商品ID:'.$shopid;
             $result['sum'] += $sumdo;
         }
         $result['marketshopids'] = array_unique($tempshopids);
     }
     if ($goodsIdArray) {
         $goodsArray = array();
         $goodsData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount  from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $goodsIdArray) . ")  order by shopid asc  ");
         foreach ($goodsData as $goodsVal) {
             $goodsArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($result['goods']['data'] as $key => $val) {
             $result['goods']['data'][$key]['img'] = $goodsArray[$val['goods_id']]['img'];
             $result['goods']['data'][$key]['name'] = $goodsArray[$val['goods_id']]['name'];
             $result['goods']['data'][$key]['cost'] = $goodsArray[$val['goods_id']]['cost'];
             $result['goods']['data'][$key]['shopid'] = $goodsArray[$val['goods_id']]['shopid'];
             $result['goods']['data'][$key]['store_num'] = $goodsArray[$val['goods_id']]['shuliang'];
             $result['goods']['data'][$key]['sellcount'] = $goodsArray[$val['goods_id']]['sellcount'];
             $result['goods']['shopdata'][$goodsArray[$val['goods_id']]['shopid']]['list'][] = $key;
             $sumdo = $goodsArray[$val['goods_id']]['cost'] * $val['count'];
             $shopid = $goodsArray[$val['goods_id']]['shopid'];
             if (!isset($result['goods']['shopdata'][$shopid]['shopinfo'])) {
                 if ($shopid == 0) {
                     $result['goods']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . Mysite::$app->config['marketid'] . "' ");
                     $result['goods']['shopdata'][$shopid]['shopinfo']['shopname'] = '商城商品';
                 } else {
                     $result['goods']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . $shopid . "' ");
                 }
             }
             $result['goods']['shopdata'][$shopid]['sum'] = isset($result['goods']['shopdata'][$shopid]['sum']) ? $result['goods']['shopdata'][$shopid]['sum'] + $sumdo : $sumdo;
             $result['goods']['shopdata'][$shopid]['sumcount'] = isset($result['goods']['shopdata'][$shopid]['sumcount']) ? $result['goods']['shopdata'][$shopid]['sumcount'] + $val['count'] : $val['count'];
             //购物车中的金额累加
             $tempshopids[] = $goodsArray[$val['goods_id']]['shopid'];
             $result['sum'] += $sumdo;
         }
         $result['shopids'] = array_unique($tempshopids);
         //$result['shopinfo'] = $mysql->select_one("select * from ".Mysite::$app->config['tablepre']."shop where id in (".join(",",$result['shopids']).")  ");
     }
     return $result;
 }
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:95,代码来源:cart.php

示例5: getGoodInfo

 private function getGoodInfo($gid)
 {
     $dataArray = array();
     $mysql = new mysql_class();
     $dataArray = $mysql->select_one("select id,name,count as shuliang,cost,img,shopid,sellcount,daycount,is_goshop from " . Mysite::$app->config['tablepre'] . "goods where id=" . $gid . "  ");
     return $dataArray;
 }
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:7,代码来源:smcart.php

示例6: strtotime

            }
        } else {
            $data['orderid'] = $orderid;
            $data['status'] = $Printer->params['sta'];
            $mysql->insert($Mconfig['tablepre'] . 'printlog', $data);
        }
    } else {
        echo 'sign wrong';
    }
} else {
    //usr
    if (isset($Printer->params['usr']) && !empty($Printer->params['usr'])) {
        $nowtime = strtotime(date('Y-m-d', time()));
        //当天最小时间
        $maxtime = strtotime(date('Y-m-d', time()) . ' 23:59:59');
        $shopinfo = $mysql->select_one("select id,uid  from " . $Mconfig['tablepre'] . "shop  where  IMEI = '" . $Printer->params['usr'] . "'");
        if (!empty($shopinfo)) {
            //当店铺不为空时
            //获取订单
            $orderlist = $mysql->select_one("select *  from " . $Mconfig['tablepre'] . "order   where  shopid = '" . $shopinfo['id'] . "' and status > 0 and status < 3 and is_print = 0 and posttime > " . $nowtime . " and posttime < " . $maxtime . "");
            if (!empty($orderlist)) {
                $orderdet = $mysql->getarr("select *  from " . $Mconfig['tablepre'] . "orderdet where order_id = " . $orderlist['id'] . "");
                $contents = '订单编码:' . $orderlist['dno'] . '%%';
                $contents .= '下单时间:' . date('Y-m-d H:i:s', $orderlist['addtime']) . '%%配送时间:' . date('Y-m-d H:i:s', $orderlist['posttime']) . '%%';
                $contents .= '下单人:' . $orderlist['buyername'] . '%%电话:' . $orderlist['buyerphone'] . '' . '%%';
                $contents .= '下单地址:' . $orderlist['buyeraddress'] . '%%';
                if (!empty($orderlist['content'])) {
                    $contents .= '订单备注:' . $orderlist['content'] . '%%';
                }
                $paycontent = $orderlist['paystatus'] == 0 ? '未支付' : '已支付';
                $contents .= '订单总价' . $orderlist['allcost'] . '元,' . $paycontent . '%%';
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:31,代码来源:yprint.php


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