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<$count;$i++)
{
$sql1=$empire->query("TRUNCATE `".$tablename[$i]."`;");
}
printerror("TruncateTbSuccess","ChangeTable.php?mydbname=$dbname");
}