0
点赞
收藏
分享

微信扫一扫

php判断mysql某数据表是否存在

$isOk = tableIsExists('piwik_archive_numeric_2011_09' ,'eloo_stats' ,'localhost' ,'root' ,'root'); 


if($isOk){ 

 echo ' 指定的表存在'; 

}else{ 

 echo ' 指定的表不存在'; 

} 


 function tableIsExists($tableName, $dbName, $host, $usrName, $pwd){ 

 $IsExists = false; 

 $conn = mysql_connect($host, $usrName, $pwd); 

 $result = mysql_list_tables($dbName); 

 for ($i = 0; $i < mysql_num_rows($result); $i++) { 

 $each = mysql_tablename($result, $i); 

 //echo $each.'--->'; 

 if($each == $tableName) { 

 $IsExists= true; 

 } 

 } 

 mysql_free_result($result); 

 mysql_close($conn); 

 return $IsExists; 

}

举报

相关推荐

0 条评论