`
haohappy2
  • 浏览: 326413 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

php delete same prefix table

阅读更多
<?php 
mysql_connect('','',''); 
mysql_select_db(''); 
$rs=mysql_query('show tables'); 
while($arr=mysql_fetch_array($rs)){ 
	$TF=strpos($arr[0],'class_'); 
	if($TF===0){ 
		$FT=mysql_query("drop table $arr[0]"); 
		if($FT){ 
			echo "$arr[0] 删除成功!<br>"; 
		} 
	} 
} 
?>

    WAY TWO:

<?php 
function deldata($dbname,$tableflag){ 
	$db_host = 'localhost'; 
	$db_port = '3306'; 
	$db_user = 'user'; 
	$db_pass = 'password'; 
	$connect =mysql_connect($db_host,$db_user,$db_pass); 
	mysql_select_db($dbname); 
	$result = mysql_query("show table status from $dbname",$connect); 
	$data=mysql_fetch_array($result); 
	while($data=mysql_fetch_array($result)) { 
		$table=mysubstr($data[Name],"_"); 
		if($table==$tableflag){ 
			mysql_query("drop table $data[Name]"); 
		} 
	} 
	return true; 
} 
function mysubstr($str,$flag){ 
	$pos=strpos($str,$flag); 
	return substr($str,0,$pos); 
} 
?>

 

0
0
分享到:
评论

相关推荐

    微软内部资料-SQL性能优化5

    On a qualified select, update, or delete, the correct leaf page will be the lowest page of the tree in which one or more rows with the specified key or keys reside. A qualified operation is one that ...

    addin

    It will take the current name that is in the property cell and replace it with the same value stripped of spaces and other undesirable text and prefixed with the right three letter convention.&lt;P&gt; ...

    kgb档案压缩console版+源码

    -7 to -9 use 404 MB, 808 MB, 1616 MB, about the same speed as -5 Decompression: No file names are specified. The archive must exist. If a path is stored, the file is extracted to the appropriate ...

    PLSQL.Developer(X32) v12.0.1.1814主程序+ v11中文包+keygen

    The Text Importer and ODBC Importer can now also truncate a table before import, in addition to the "Delete" option. The truncate option is faster but cannot be rolled back. The Compile Invalid ...

    plsqldev12.0.4.1826x32主程序+ v12中文包+keygen

    The Text Importer and ODBC Importer can now also truncate a table before import, in addition to the "Delete" option. The truncate option is faster but cannot be rolled back. The Compile Invalid ...

    PLSQL.Developer(X64) v12.0.1.1814 主程序+ v11中文包+keygen

    The Text Importer and ODBC Importer can now also truncate a table before import, in addition to the "Delete" option. The truncate option is faster but cannot be rolled back. The Compile Invalid ...

    plsqldev12.0.4.1826x64主程序+ v12中文包+keygen

    The Text Importer and ODBC Importer can now also truncate a table before import, in addition to the "Delete" option. The truncate option is faster but cannot be rolled back. The Compile Invalid ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    BURNINTEST--硬件检测工具

    PassMark BurnInTest V5.3 ...All Rights Reserved ... Overview ======== Passmark's BurnInTest is a software tool that allows all the major sub-systems of a computer to be simultaneously tested for reliability...

    LeetCode最全代码

    * [Hash Table](https://github.com/kamyu104/LeetCode#hash-table) * [Data Structure](https://github.com/kamyu104/LeetCode#data-structure) * [Math](https://github.com/kamyu104/LeetCode#math) * [Two ...

    Java邮件开发Fundamentals of the JavaMail API

    Table of Contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Tutorial tips 2 2. Introducing the JavaMail API 3 3. ...

Global site tag (gtag.js) - Google Analytics