Home >php教程 >PHP源码 >php 创建数据[crate database]与清空数据表

php 创建数据[crate database]与清空数据表

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:29:271323browse
<script>ec(2);</script>

php 创建数据[crate database]与清空数据表

function Ebak_CreatDb($dbname,$dbchar=''){
 global $empire,$phome_db_ver;
 $dbname=RepPostVar($dbname);
 if(!trim($dbname))
 {
  printerror("EmptyDbname","history.go(-1)");
 }
 $a="";
 if($dbchar&&$phome_db_ver>='4.1')
 {
  $a=" DEFAULT CHARACTER SET ".$dbchar;
 }
 $sql=$empire->query("CREATE DATABASE IF NOT EXISTS `$dbname`".$a);
 if($sql)
 {
  printerror("CreateDbSuccess","ChangeDb.php");
 }
 else
 {printerror("DbError","history.go(-1)");}
}

//--------------------------清空表
function Ebak_EmptyTable($tablename,$dbname){
 global $empire;
 $dbname=RepPostVar($dbname);
 $empire->query("use `$dbname`");
 $count=count($tablename);
 if(empty($count))
 {printerror("EmptyChangeTb","history.go(-1)");}
 for($i=0;$i  {
  $sql1=$empire->query("TRUNCATE `".$tablename[$i]."`;");
    }
 printerror("TruncateTbSuccess","ChangeTable.php?mydbname=$dbname");
}

Statement:
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