123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- defined( 'IN_WEB') or die( 'Include Error!');
- /**
- * 获取数据库的配置信息
- * YANG丶 2019年5月15日10:39:21
- */
- class ModelReadconfig
- {
- public function getCon($item,$title){
- if (empty($item) || empty($title)) {
- return false;
- }
- $ret = oo::commonOprRedis('common')->hGet(otable::basicConfig(),$item.'-'.$title);
- if($ret === false){
- $table = otable::basicConfig();
- $sql = "SELECT content FROM {$table} WHERE item = '{$item}' AND title = '{$title}'";
- $res = oo::commonOprDb('common')->getOne($sql,1);
- if(isset($res['content'])){
- oo::commonOprRedis('common')->hSet(otable::basicConfig(),$item.'-'.$title,$res['content']);
- return $res['content'];
- }
- return null;
- }
- return $ret;
- }
-
- public function getSysCon($item,$title){
- if (empty($item) || empty($title)) {
- return false;
- }
- $ret = oo::commonOprRedis('common')->hGet(okeys::systemConfig(),$item.'-'.$title);
- if($ret === false){
- $table = otable::systemConfig();
- $sql = "SELECT content FROM {$table} WHERE item = '{$item}' AND title = '{$title}'";
- $res = oo::commonOprDb('common')->getOne($sql,1);
- oo::commonOprRedis('common')->hSet(otable::systemConfig(),$item.'-'.$title,$res['content']);
- return $res['content'];
- }
- return $ret;
- }
- public function setSysCon($item,$title,$content){
- if (empty($item) || empty($title)) {
- return false;
- }
- oo::commonOprRedis('common')->hDel(okeys::systemConfig(),$item.'-'.$title);
- $table = otable::systemConfig();
- $content = addslashes($content);
- $sql = "UPDATE {$table} SET content='{$content}' WHERE item = '{$item}' AND title = '{$title}'";
- oo::commonOprDb('common')->query($sql);
- return 1;
- }
-
- public function getStaticConfigPath($config = "",$sid=1){
- $ret = oo::commonOprRedis('common')->hGetAll(okeys::StaticConfig());
- if(empty($ret)){
- /////////////////////////////////////////////////
- oo::logs()->debug3(['msg' => 'get redis '. okeys::StaticConfig().' key fail','sid' => $sid],'configredis_expire');
- /////////////////////////////////////////////////
- $tb = otable::StaticConfig();
- $sql = "SELECT * FROM {$tb} WHERE 1";
- $res = oo::commonOprDb('common')->getAll($sql,MYSQLI_ASSOC);
- $ret = [];
- foreach ($res as $row){
- $ret[$row['config']] = $row['path'];
- oo::commonOprRedis('common')->hSet(okeys::StaticConfig(),$row['config'],$row['path']);
- }
- }
- if($sid == 1){
- $ret['Version'] = $ret['AndroidVersion'];
- }else if($sid == 2){
- $ret['Version'] = $ret['IosVersion'];
- }
- if(!empty($config)){
- return $ret[$config];
- }
- unset($ret['AndroidVersion']);
- unset($ret['IosVersion']);
- unset($ret['VivoVersion']);
- return $ret;
- }
- public function getStaticMd5ConfigPath(){
- $ret = oo::commonOprRedis('common')->hGetAll(okeys::StaticMd5Config());
- if($ret != false){
- return $ret;
- }else{
- /////////////////////////////////////////////////
- oo::logs()->debug3(['msg' => 'get redis '. okeys::StaticMd5Config().' key fail'],'configredis_expire');
- /////////////////////////////////////////////////
- $tb = otable::StaticMd5Config();
- $ret = oo::commonOprDb('common')->getAll("SELECT * FROM {$tb}",MYSQLI_ASSOC);
- $out = [];
- foreach ($ret as $row){
- $out[$row['config']] = $row['path'];
- }
- oo::commonOprRedis('common')->hMset(okeys::StaticMd5Config(),$out);
- return $out;
- }
- }
- public function getLangStaticConfigPath(){
- $ret = oo::commonOprRedis('common')->hGetAll(okeys::LangStaticConfig());
- if($ret != false){
- return $ret;
- }else{
- $tb = otable::LangStaticConfig();
- $sql = "SELECT * FROM {$tb} WHERE 1";
- $ret = oo::commonOprDb('common')->getAll($sql,MYSQLI_ASSOC);
- $out = [];
- foreach ($ret as $row){
- $out[$row['config']] = $row['path'];
- oo::commonOprRedis('common')->hSet(okeys::LangStaticConfig(),$row['config'],$row['path']);
- }
- return $out;
- }
- }
-
- }
|