m_name}'"; if($this->sqlone('applist',$where) != false){ echo '请勿重复安装'; return '请勿重复安装'; exit; } do{ $this->no = mt_rand(2001,9999); $stall = $this->sqlone('applist'); } while ($stall != false); //开始执行程序[需要的东西可以在下面执行了] $this->appsql(); //再执行自定义的一些表SQL //$this->zdysql(); //安装其他 $this->mydefault(); echo '安装成功'; return '安装成功'; } //自定义SQL private function zdysql() { global $_M; } //执行APP相关的表数据插入 private function appsql() { global $_M; //注册应用 $field = "no='{$this->no}',ver='{$this->ver}',m_name='{$this->m_name}',m_class='index',m_action='doindex',appname='\$_M[''word''][''cleaner_name'']',info='\$_M[''word''][''cleaner_info'']',addtime='1473590889',updatetime=''"; $this->addsql('applist',$field); } //全局默认参数 private function mydefault() { global $_M; //安装语言包 $cl = $this->langsql(); } //公共查询方法 private function sqlone($tname,$where = '') { global $_M; $table = $_M['table'][$tname]; if(!$where){ $where = "no='{$this->no}'"; } return DB::get_one("select * from {$table} where {$where}"); } //公共查询方法 private function sqlall($tname,$where = '') { global $_M; $table = $_M['table'][$tname]; if(!$where){ $where = "no='{$this->no}'"; } return DB::get_all("select * from {$table} where {$where}"); } //公共写入方法 private function addsql($tname,$field = '') { global $_M; $table = $_M['table'][$tname]; DB::query("INSERT INTO {$table} SET {$field}"); } #云网开发工具生成 private function langsql() { global $_M; $file = PATH_ALL_APP.$this->m_name.'/lang/'.$this->m_name.'.sql'; $_sql = file_get_contents($file); $_arr = explode("#;#;", $_sql); foreach ($_arr as $val) { $val = str_replace("{\$_M['config']['tablepre']}", $_M['config']['tablepre'], $val); $val = str_replace("{\$this->no}", $this->no, $val); DB::query($val); } } } ?>