當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。