获取数据库菜单利用缓存处理

来源:互联网 发布:生物网络知识构建图 编辑:程序博客网 时间:2024/05/16 19:00

 

require_once("./include/common.inc.php");
$istrue=$_REQUEST['creatfile'];
$number=$_REQUEST['tag']?'':1;
$ID=$_REQUEST['id'];
$today=date('Y-m-d');
$datetime=$_REQUEST['date']!=''?$_REQUEST['date']:$today;

//获取菜单数据
if($istrue){
 $content=getSjcxTree();
 $string="<?php /n return ".var_export($content,true)."?>";
 $filepath=WEB_ROOT.'/Cache/sjcxmenu.php';
 file_put_contents($filepath,$string);
}
$menu=include_once(WEB_ROOT.'/Cache/sjcxmenu.php');//getSjcxTree();
$info=getContentById($ID,$datetime);
$image=getImage($ID);

 


$i=0;
foreach($menu as $v){
 if($menu[$i]['ID']==$ID){
  $className=$v['ClassName'];
 }
 $i++;
}

include_once('sjcx.php');

//本页面使用到的方法
/**
 * 获取手机彩信库栏目数据
 */
function getSjcxTree(){
  global $db;
 $sql="select * from tclasstree where ParentClassID='C4918' order by OrderBy";
 $query=$db->query($sql);
    while($result = $db->fetch_array($query)) {
    $res[]=$result;
    }
    return $res;
}

运行前需要自己部署

require_once("./include/common.inc.php");
$istrue=$_REQUEST['creatfile'];
$number=$_REQUEST['tag']?'':1;
$ID=$_REQUEST['id'];
$today=date('Y-m-d');
$datetime=$_REQUEST['date']!=''?$_REQUEST['date']:$today;

//获取菜单数据
if($istrue){
 $content=getSjcxTree();
 $string="<?php /n return ".var_export($content,true)."?>";
 $filepath=WEB_ROOT.'/Cache/sjcxmenu.php';
 file_put_contents($filepath,$string);
}
$menu=include_once(WEB_ROOT.'/Cache/sjcxmenu.php');//getSjcxTree();
$info=getContentById($ID,$datetime);
$image=getImage($ID);

 


$i=0;
foreach($menu as $v){
 if($menu[$i]['ID']==$ID){
  $className=$v['ClassName'];
 }
 $i++;
}

include_once('sjcx.php');

//本页面使用到的方法
/**
 * 获取手机彩信库栏目数据
 */
function getSjcxTree(){
  global $db;
 $sql="select * from tclasstree where ParentClassID='C4918' order by OrderBy";
 $query=$db->query($sql);
    while($result = $db->fetch_array($query)) {
    $res[]=$result;
    }
    return $res;
}

运行前需要自己部署

 

原创粉丝点击