Home > php教程 > php手册 > TP获得mysql版本及mysql数据库大小

TP获得mysql版本及mysql数据库大小

WBOY
Release: 2016-06-07 11:42:23
Original
1835 people have browsed it

TP获得mysql版本及mysql数据库大小
<?php <br /> namespace Admin\Controller;<br> use Think\Controller;<br> class SystemController extends AdminController<br> {<br>     protected function _model(){<br>         return new \Think\Model();<br>     }<br> <br>     public function indexAction()<br>     {<br>         layout( true );<br>         $this->sysinfo = array(<br>             'os' => $_SERVER["SERVER_SOFTWARE"], //获取服务器标识的字串<br>             'version' => PHP_VERSION, //获取PHP服务器版本<br>             'time' => date("Y-m-d H:i:s", time()), //获取服务器时间<br>             'pc' => $_SERVER['SERVER_NAME'], //当前主机名<br>             'osname' => php_uname(), //获取系统类型及版本号<br>             'language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'], //获取服务器语言<br>             'port' => $_SERVER['SERVER_PORT'], //获取服务器Web端口<br>             'max_upload' => ini_get("file_uploads") ? ini_get("upload_max_filesize") : "Disabled", //最大上传<br>             'max_ex_time' => ini_get("max_execution_time")."秒", //脚本最大执行时间<br>             'mysql_version' => $this->_mysql_version(),<br>             'mysql_size' => $this->_mysql_db_size(),<br>         );<br>         $this->display();<br>     }<br> <br>     private function _mysql_version()<br>     {<br>         $Model = self::_model();<br>         $version = $Model->query("select version() as ver");<br>         return $version[0]['ver'];<br>     }<br> <br>     private function _mysql_db_size()<br>     {        <br>         $Model = self::_model();<br>         $sql = "SHOW TABLE STATUS FROM ".C('DB_NAME');<br>         $tblPrefix = C('DB_PREFIX');<br>         if($tblPrefix != null) {<br>             $sql .= " LIKE '{$tblPrefix}%'";<br>         }<br>         $row = $Model->query($sql);<br>         $size = 0;<br>         foreach($row as $value) {<br>             $size += $value["Data_length"] + $value["Index_length"];<br>         }<br>         return round(($size/1048576),2).'M';<br>     }<br> }不足之处望指点!http://www.yi210.com/archives/919.html

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template