當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysql_class::getarr方法代碼示例

本文整理匯總了PHP中mysql_class::getarr方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysql_class::getarr方法的具體用法?PHP mysql_class::getarr怎麽用?PHP mysql_class::getarr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mysql_class的用法示例。


在下文中一共展示了mysql_class::getarr方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
     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 ($goodsIdArray) {
         $goodsArray = array();
         $mysql = new mysql_class();
         $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'];
             //購物車中的金額累加
             $tempshopids[] = $goodsArray[$val['goods_id']]['shopid'];
             $result['sum'] += $goodsArray[$val['goods_id']]['cost'] * $val['count'];
         }
         $result['shopids'] = array_unique($tempshopids);
         $result['shopinfo'] = $mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where id in (" . join(",", $result['shopids']) . ")  ");
     }
     return $result;
 }
開發者ID:snamper,項目名稱:xiaoshuhaochi,代碼行數:43,代碼來源:newcart.php

示例3: 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

示例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;
     $mysql = new mysql_class();
     $goodsIdArray = array();
     $backdata = $result;
     if (count($cartValue) > 0) {
         $ids = array_keys($cartValue);
         $ids = join(',', $ids);
         $shopinfo = array();
         if (!empty($ids)) {
             $shoplist = $mysql->getarr("select id,shopname,shoplogo,shortname,shoptype from " . Mysite::$app->config['tablepre'] . "shop   where id in (" . $ids . ")  ");
             foreach ($shoplist as $key => $value) {
                 $shopinfo[$value['id']] = $value;
             }
         }
         foreach ($cartValue as $key => $value) {
             if ($key == 0) {
                 $backdata['list'][$key]['shopinfo'] = array('id' => 0, 'shopname' => '商城');
             } else {
                 $backdata['list'][$key]['shopinfo'] = $shopinfo[$key];
             }
             foreach ($value as $k => $v) {
                 $backdata['list'][$key]['data'][$k]['count'] = $v;
                 $backdata['list'][$key]['data'][$k]['id'] = $k;
                 $backdata['list'][$key]['count'] = 0;
                 $backdata['list'][$key]['sum'] = 0;
                 $backdata['list'][$key]['bagcost'] = 0;
                 $goodsIdArray[] = $k;
                 $backdata['count'] += $v;
             }
         }
     }
     if ($goodsIdArray) {
         $goodsArray = array();
         $goodsData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount,bagcost,typeid,daycount  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 ($goodsData as $key => $val) {
             $backdata['list'][$val['shopid']]['data'][$val['id']]['img'] = $val['img'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['name'] = $val['name'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['cost'] = $val['cost'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['shopid'] = $val['shopid'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['store_num'] = $val['shuliang'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['sellcount'] = $val['sellcount'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['daycount'] = $val['daycount'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['bagcost'] = $val['bagcost'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['typeid'] = $val['typeid'];
             $backdata['list'][$val['shopid']]['sum'] += $val['cost'] * $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
             $backdata['list'][$val['shopid']]['count'] += $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
             $backdata['list'][$val['shopid']]['bagcost'] += $backdata['list'][$val['shopid']]['data'][$val['id']]['count'] * $val['bagcost'];
             $backdata['sum'] += $val['cost'] * $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
         }
     }
     return $backdata;
 }
開發者ID:snamper,項目名稱:xiaoshuhaochi,代碼行數:64,代碼來源:smcart.php

示例5: strtotime

    } 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 . '%%';
                foreach ($orderdet as $key => $value) {
                    $contents .= $value['goodsname'] . '(' . $value['goodscount'] . '份)%%';
                }
                // print_r($contents);
                //contents
                $contents = mb_convert_encoding($contents, 'GB2312', 'UTF-8');
開發者ID:snamper,項目名稱:xiaoshuhaochi,代碼行數:31,代碼來源:yprint.php


注:本文中的mysql_class::getarr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。