本文整理匯總了PHP中CommonUtil::metaData方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonUtil::metaData方法的具體用法?PHP CommonUtil::metaData怎麽用?PHP CommonUtil::metaData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonUtil
的用法示例。
在下文中一共展示了CommonUtil::metaData方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: settle
public function settle($term)
{
$this->term = $term;
$conn = Yii::app()->db;
$msg = "";
$ltrRec = $conn->createCommand("select term as id,settling,status from tbl_ltr where term=:term")->queryRow(true, array(":term" => $this->term));
if ($ltrRec == false) {
$msg = "期數不對,請重新登錄再試";
$ltrRec = array("id" => $this->term, "settling" => false, "status" => 0);
} elseif ($ltrRec['status'] == 0) {
$msg = "本期還未開盤";
} elseif ($ltrRec['settling'] == 1) {
$msg = "結賬中,請稍等";
} elseif ($ltrRec['status'] == 2) {
$msg = "已結帳,無法重複結賬";
}
if (strlen($msg) > 0) {
CommonUtil::metaData($ltrRec, array("id" => '', "settling" => 'bool', "status" => 'int'), false);
return CJSON::encode(array("ltr" => $ltrRec, "msg" => $msg, "success" => false));
}
$codes = $conn->createCommand("select zm1,zm2,zm3,zm4,zm5,zm6,tm from tbl_ltr_codes where term=:term")->queryRow(true, array(":term" => $this->term));
foreach ($codes as $code) {
if ($code == null || strlen($code) < 2) {
CommonUtil::metaData($ltrRec, array('', 'bool', 'int'));
return CJSON::encode(array("ltr" => $ltrRec, "msg" => "有號碼為空", "success" => false));
}
}
$conn->createCommand("update tbl_ltr set settling=1 where term='{$this->term}'")->execute();
/*$dataReader=$conn->createCommand("select id,betSum,ltrBtcId,ltrTypeId,betType,betCode,rate0,rate1,rebate from tbl_bet where termid=:term")->query(array(":term"=>$this->term));
while(($bet=$dataReader->read())!==false) {
$this->isBetWin($bet['id'],$bet['betSum'],$bet['ltrBtcId'],$bet['ltrTypeId'],$bet['betType'],$bet['betCode'],$bet['rate0'],$bet['rate1'],$bet['rebate'],$codes);
}*/
$this->settleType($term);
//update bet
//update term
Yii::app()->db->createCommand("update tbl_ltr set settling=0,status=2,tmstatus=1,ftmstatus=1 where term='{$this->term}'")->execute();
Yii::app()->cache->set('status', 2);
Yii::app()->cache->set('tmstatus', 1);
Yii::app()->cache->set('ftmstatus', 1);
Yii::log("backgroud settle success", CLogger::LEVEL_ERROR, 'php');
}
示例2: actionRefreshJson
//.........這裏部分代碼省略.........
} elseif ($bet['ltrBtcId'] == 'tmsb' || substr($bet['ltrBtcId'], -3) == '_sb') {
for ($i = 0; $i < 49; $i++) {
$r = $sbs[$i];
$btcs[$abBtc]['win'][$i] -= $r == $betCbIdx ? $winSum : -$noWinSum;
$btcs[$abBtc]['bet'][$i] += $r == $betCbIdx ? $betResult / 12 : 0;
}
} elseif ($bet['ltrBtcId'] == 'tmqs' || substr($bet['ltrBtcId'], -3) == '_qs') {
for ($i = 0; $i < 48; $i++) {
$r = CommonUtil::getSxCode($i + 1);
$r = in_array($i, $jqs) ? 0 : 1;
$btcs[$abBtc]['win'][$i] -= $r == $betCbIdx ? $winSum : -$noWinSum;
$btcs[$abBtc]['bet'][$i] += $r == $betCbIdx ? $betResult / 24 : 0;
}
}
$btcs[$bet['ltrBtcId']]['bet'][$betCbIdx] += floatval($bet['bet']);
$btcs[$bet['ltrBtcId']]['win'][$betCbIdx] += floatval($bet['win']);
} else {
$btcs[$bet['ltrBtcId']]['bet'][$betCbIdx] += floatval($bet['bet']);
$btcs[$bet['ltrBtcId']]['win'][$betCbIdx] += floatval($bet['win']);
}
}
//[ "id","cbType","names", "sum","flag" ] "items":[[],[],[[48,0,"牛,虎,蛇,馬,羊,狗",9.0,48]]]
if ($_POST['btcs'] == 'lm' || $_POST['btcs'] == 'dzy' || $_POST['btcs'] == 'mx' || $_POST['btcs'] == 'wsl' || $_POST['btcs'] == 'sxl' || $_POST['btcs'] == 'bz') {
$items = array();
$cbIdx = intval($_POST['cbIdx']);
$items[] = array();
$items[] = array();
//$items[]=$conn->createCommand("select id,SUBSTRING(ltrTypeId,instr(ltrTypeId,'_')+1),betType,betSum,SUBSTRING(ltrTypeId,instr(ltrTypeId,'_')+1) from tbl_bet where `ltrBtcId` ='{$_POST['btcs']}' order by ltrTypeId")->queryAll(false);
$itemWhere = "";
if ($cbIdx != -1) {
$itemWhere = "and `ltrTypeId` ='" . $_POST['btcs'] . "_" . $cbIdx . "'";
/*}else{
$itemWhere="and `ltrBtcId` ='".$_POST['btcs']."'";
}*/
$btcLen = strlen($_POST['btcs']) + 1 + 1;
$itemRec = $conn->createCommand("select id,substring(ltrTypeId,{$btcLen}),betCode,sum(betSum{$sumHuo}) as betSum,id from tbl_bet where termid='{$this->term}' {$itemWhere} {$whereStatUser} group by ltrTypeId,betCode order by betSum desc,REPLACE(REPLACE(REPLACE(REPLACE(CONCAT(',',betCode,','),',1,',',01,'),',2,',',02,'),',3,',',03,'),',4,',',04,') asc")->queryAll(false);
/*for($itemI=0;$itemI<count($itemRec);$itemI++){
$itemCodes=split(',',$itemRec[$itemI][2]);
for($itemJ=0;$itemJ<count($itemCodes);$itemJ++){
$itemCodes[$itemJ]=str_pad($itemCodes[$itemJ]+1, 2, "0", STR_PAD_LEFT);
}
$itemRec[$itemI][2]=implode(',',$itemCodes);
}*/
CommonUtil::metaData($itemRec, array('int', 'int', '', 'float', 'int'));
if (isset($_POST['itemIds']) && strlen($_POST['itemIds']) > 0) {
if (count($itemRec) == count(split(',', $_POST['itemIds']))) {
$items[] = array();
} else {
$items[] = $itemRec;
}
} else {
$items[] = $itemRec;
}
foreach ($itemRec as $itemI) {
$betCodes = split(',', $itemI[2]);
//$betCodes is nameIdx
$codeLen = count($betCodes);
foreach ($betCodes as $betCode) {
$btcs[$_POST['btcs']]['name'][$betCode] += floatval($itemI[3] / $codeLen);
//$btcs[$_POST['btcs']]['namev'][]="$betCode,$itemI[3],".floatval($itemI[3]/$codeLen);
}
}
} else {
$items[] = array();
}
$btcs[$_POST['btcs']]['items'] = $items;
$btcs[$_POST['btcs']]["minFlag"] = -1;
$btcs[$_POST['btcs']]["maxFlag"] = 0;
if ($cbIdx != -1) {
$btcs[$_POST['btcs']]["cbIdx"] = $cbIdx;
}
//if(!isset($btcs[$_POST['btcs']]['namev'])){
// $btcs[$_POST['btcs']]['namev']=array();
//}
}
$refresh['btcs'] = $btcs;
}
if (Yii::app()->user->getState('countDown') === NULL) {
Yii::app()->user->setState('countDown', true);
}
if (Yii::app()->user->getState('countDown') == true) {
$refresh['remainTimes'] = array($notTeAutoRemainTime, $teAutoRemainTime);
}
$refresh['autoCloseTimes'] = array($ltrRec['notTeAutoCloseTime'], $ltrRec['teAutoCloseTime'], $ltrRec['teAutoCloseTime']);
$refresh['term'] = $this->term;
$code = $conn->createCommand("select zm1,zm2,zm3,zm4,zm5,zm6,tm from tbl_ltr_codes where term='{$this->term}'")->queryRow(false);
$refresh['code'] = $code;
$ztTypes = '';
for ($i = 0; $i < 6; $i++) {
$ztTypes .= ",zt_{$i},zt_{$i}_ds,zt_{$i}_dx,zt_{$i}_hsds,zt_{$i}_wsdx,zt_{$i}_qs,zt_{$i}_sb";
}
$ztTypes = substr($ztTypes, 1);
$statTypes = array('tm,tmds,tmdx,tmhsds,tmwsdx,tmqs,tmsb', 'zm,zhds,zhdx', 'lm', 'tx', 'bbds,bbdx', 'mx', 'sx,ws', 'sxl,wsl', 'bz', $ztTypes, 'dzy', 'qsb', 'zx', 'qm_0,qm_1,qm_2,qm_3,qm_4,qm_5,qm_6,qm_7');
foreach ($statTypes as $statType) {
$statRec = $conn->createCommand("select sum(if(betuserid='" . $userid . "'," . ($huo == 1 ? "0" : "-betSum") . ",betSum" . $sumHuo . ")) as bet from tbl_bet where termid='" . $this->term . "' and `ltrBtcId` in ('" . str_replace(",", "','", $statType) . "') and statUser_{$roleid}='" . $userid . "'")->queryRow(false);
$refresh['stat'][] = $statRec[0];
}
echo CJSON::encode($refresh);
Yii::app()->end();
}
示例3: actionRebatebhJson
/**
* user az999
* @return unknown_type
*/
public function actionRebatebhJson()
{
$this->layout = false;
header('Content-type: application/json');
$rebates = Yii::app()->db->createCommand("select idx,rebate0 as rebate from tbl_default_rebate_bh where userid='{$_POST['user']}' order by idx")->queryAll();
CommonUtil::metaData($rebates, array("idx" => 'int', "rebate" => 'float'));
echo CJSON::encode(array("data" => $rebates, "success" => true));
Yii::app()->end();
}
示例4: actionBetItemsJson
/**
* bet=1
* btc tm
idx 0
limit 20
pan 0
start 0
cbNames
* "id", "betTime", "betType", "rate", "betSum", "prorate","prSum", "betUser", "bhUser"
* @return unknown_type
*/
public function actionBetItemsJson()
{
//{"count":1,"items":[[89220,"21:24:39","特碼A01","42.38",1000.0,0.6,600.0,"hy6",""]],"success":true}
$this->layout = false;
header('Content-type: application/json');
$conn = Yii::app()->db;
$type = $_POST['btc'] . '_' . $_POST['idx'];
$where = "ltrTypeid='{$type}'";
if (isset($_POST['pan']) && ($_POST['btc'] == 'tm' || $_POST['btc'] == 'zm')) {
$pan = $_POST['pan'];
if ($pan > 1) {
$type0 = $_POST['btc'] . '_0_' . $_POST['idx'];
$type1 = $_POST['btc'] . '_1_' . $_POST['idx'];
$where = "(ltrTypeid='{$type0}' or ltrTypeid='{$type1}')";
} else {
$type = $_POST['btc'] . '_' . $pan . '_' . $_POST['idx'];
$where = "ltrTypeid='{$type}'";
}
}
if (isset($_POST['cbNames'])) {
$cbNames = $_POST['cbNames'];
/*$itemCodes=split(',',$_POST['cbNames']);
for($itemJ=0;$itemJ<count($itemCodes);$itemJ++){
$itemCodes[$itemJ]=intval($itemCodes[$itemJ])-1;
}
$cbNames=implode(',',$itemCodes);*/
$where .= " and betCode='{$cbNames}'";
}
$where .= " and termid='{$this->term}'";
$role = Yii::app()->user->role;
if (isset($_POST['bet']) && $_POST['bet'] == 1) {
$where .= " and betUserId='" . Yii::app()->user->id . "'";
} else {
$where .= " and statUser_{$role}='" . Yii::app()->user->id . "' and betUserId<>'" . Yii::app()->user->id . "'";
}
$limit = " limit {$_POST['start']},{$_POST['limit']}";
$sql = "select id,SUBSTRING(betTime,12),betType,rate,betSum,prorate_{$role},prorate_{$role}*betSum,betUserId,bhUserId from tbl_bet where {$where}";
//echo $sql;
$items = $conn->createCommand($sql . $limit)->queryAll(false);
$sql = "select count(*) from " . substr($sql, strpos($sql, " from") + 6);
$count = $conn->createCommand($sql)->queryRow(false);
CommonUtil::metaData($items, array('int', '', '', '', 'float', 'float', 'float', '', ''));
echo CJSON::encode(array("count" => $count[0], "items" => $items, "success" => true));
Yii::app()->end();
}
示例5: actionSettle
/**
* 結賬
* @return unknown_type
*/
public function actionSettle()
{
$this->layout = false;
header('Content-type: application/json');
//$site=Yii::app()->user->site;
$conn = Yii::app()->db;
$msg = "";
$ltrRec = $conn->createCommand("select term as id,settling,status from tbl_ltr where term=:term")->queryRow(true, array(":term" => $this->term));
if ($ltrRec == false) {
$msg = "期數不對,請重新登錄再試";
$ltrRec = array("id" => $this->term, "settling" => false, "status" => 0);
} elseif ($ltrRec['status'] == 0) {
$msg = "本期還未開盤";
} elseif ($ltrRec['settling'] == 1) {
$msg = "結賬中,請稍等";
} elseif ($ltrRec['status'] == 2) {
$msg = "已結帳,無法重複結賬";
}
if (strlen($msg) > 0) {
CommonUtil::metaData($ltrRec, array("id" => '', "settling" => 'bool', "status" => 'int'), false);
echo CJSON::encode(array("ltr" => $ltrRec, "msg" => $msg, "success" => false));
Yii::app()->end();
}
$codes = $conn->createCommand("select * from tbl_ltr_codes where term=:term")->queryRow(true, array(":term" => $this->term));
foreach ($codes as $code) {
if ($code == null || strlen($code) < 2) {
CommonUtil::metaData($ltrRec, array('', 'bool', 'int'));
echo CJSON::encode(array("ltr" => $ltrRec, "msg" => "有號碼為空", "success" => false));
Yii::app()->end();
break;
}
}
//CommonUtil::runBackGround("/bet/runBackSettle.do");
$betService = new BetService();
echo $betService->settle($this->term);
//{"ltr":{"id":2011013,"settling":false,"status":2,"codes":["01","02","03","04","05","06","49"]},"msg":"已結帳,無法重複結賬","success":false}
$ltr = array("id" => $this->term, "settling" => true, "status" => 1);
echo CJSON::encode(array("ltr" => $ltr, "success" => true));
Yii::app()->end();
}