remap_table方法是用的一个框架写的:
$gvs = $this->pageObj->get;是获取通过get方式传递过来的数据;
$mem = $this->pageObj->memcache;是实例化一个memcache对象;
其他的基本上就没有框架的痕迹了
protected function remap_table($sql) {
$gvs = $this->pageObj->get;
$host="127.0.0.1";
$port="11211";
// $mem = new Memcache();
// $link = @$mem->connect($host, $port);
// //判断是否连接成功
// if(!$link)
// return 'memcache服务器连接失败';
$mem = $this->pageObj->memcache;
//判断是否属于搜索
if($gvs->key != ''){
//模糊查询
$findIndex = $gvs->key;
$items = $mem->getExtendedStats('items');
$items = $items["$host:$port"]['items'];
foreach($items as $key=>$values){
$number=$key;
$str=$mem->getExtendedStats("cachedump", $number, 0);
$line=$str["$host:$port"];
if(is_array($line) && count($line)>0){
$datas = array();
$num = 0;
foreach($line as $key=>$value){
if(strpos($key, $findIndex) === false){
continue;
}
$datas[$num]['id'] = $num+1;
$datas[$num]["k"] = $key;
$info = $mem->get($key);
if(strlen($info)>150){
$info = substr($info, 0, 150);
$info = $info.'...';
}
$datas[$num]["val"] = $info;
$num++;
}
}
return $datas;
}
}else{
$items = $mem->getExtendedStats('items');
$items = $items["$host:$port"]['items'];
foreach($items as $key=>$values){
$number=$key;
$str=$mem->getExtendedStats("cachedump", $number, 0);
$line=$str["$host:$port"];
if(is_array($line) && count($line)>0){
$datas = array();
$num = 0;
foreach($line as $key=>$value){
$datas[$num]['id'] = $num+1;
$datas[$num]["key"] = $key;
$info = $mem->get($key);
if(strlen($info)>150){
$info = substr($info, 0, 150);
$info = $info.'...';
}
$datas[$num]["val"] = $info;
$num++;
}
}
//$datas[100] = array("key"=>111,"val"=>222);
//$datas[101] = array("key"=>'13q1',"val"=>2322);
// print_r($datas);
return $datas;
}
}
}