本文整理匯總了PHP中response::getEncode方法的典型用法代碼示例。如果您正苦於以下問題:PHP response::getEncode方法的具體用法?PHP response::getEncode怎麽用?PHP response::getEncode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類response
的用法示例。
在下文中一共展示了response::getEncode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
public function check()
{
$this->params['app_id'] = $appid = isset($_POST['app_id']) ? $_POST['app_id'] : '';
$this->params['version_id'] = $versionid = isset($_POST['version_id']) ? $_POST['version_id'] : '';
$this->params['version_mini'] = $versionmini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
$this->params['did'] = $did = isset($_POST['did']) ? $_POST['did'] : '';
$this->params['encrypt_did'] = $encryptdid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
// 接口數據校驗省略,實際使用時須加
if (!is_numeric($appid)) {
response::getEncode(300, 'params error', '');
exit;
}
// 判斷APP是都要加密
$this->app = $this->getApp($appid);
if (!$this->app) {
response::getEncode(500, 'params error', '');
exit;
}
/*
if($encryptdid!=md5($did,$this->app['key'])){
response::getEncode(500,'md5 error','');
exit();
}
*/
}
示例2: index
public function index()
{
// app請求參數校驗
$this->check();
$error = isset($_POST['error_log']) ? $_POST['error_log'] : '';
if (!$error) {
response::getEncode(0, 'logs empty', '');
exit;
}
$sql = "insert into log(error) values('start error')";
$connect = DB::getInstance()->connect($dbConfig);
mysqli_query($connect, $sql);
response::getEncode(0, 'logs send success', '');
exit;
}
示例3: get
public function get()
{
if (!is_numeric($this->_page) || !is_numeric($this->_pagesize)) {
response::getEncode(100, 'request error', '');
exit;
}
// get from cache
global $dbConfig;
global $cacheConfig;
$cache = new Cache();
$rdata = array();
// 存在緩存時,直接獲取緩存並返回
/*
if($rdata=$cache->cacheData('index_cache_'.$this->_page.'-'.$this->_pagesize)){
response::getEncode(0,'request success',$rdata);
exit();
}
*/
// 使用memcache緩存
$this->_memcache->connect($cacheConfig['host'], $cacheConfig['port']);
if ($rdata = $this->_memcache->get('index_cache_' . $this->_page . '-' . $this->_pagesize)) {
var_dump('get cache');
response::getEncode(0, 'request success', $rdata);
exit;
}
// 否則讀取數據庫,並且更新緩存
$offset = ($this->_page - 1) * $this->_pagesize;
$sql = "select * from mall where status=1 order by price limit " . $offset . ',' . $this->_pagesize;
// 異常接收
try {
$conn = DB::getInstance()->connect($dbConfig);
} catch (Exception $e) {
// $e->getMessage()
response::getEncode(400, 'database connect error', '');
exit;
}
$res = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$rdata[] = $row;
}
//$cache->cacheData('index_cache_'.$this->_page.'_'.$this->_pagesize,$rdata,$cacheConfig['expiretime']);
$this->_memcache->add('index_cache_' . $this->_page . '-' . $this->_pagesize, $rdata);
var_dump('set cache');
response::getEncode(0, 'request success', $rdata);
exit;
}
示例4: isset
<?php
/**
* get
* http://***?type=firstpage&page=1&pagesize=10
*/
require_once 'Controllers/firstpage.class.php';
require_once 'Controllers/defaultpage.class.php';
require_once 'libs/Response.class.php';
// route
$type = isset($_GET['type']) ? $_GET['type'] : 'default';
switch ($type) {
case 'firstpage':
$firstpage = new firstpage();
return $firstpage->get();
break;
default:
$res = new response();
return response::getEncode(200, 'request type error', '');
break;
}