Last active
August 29, 2015 13:58
-
-
Save kruxor/10208209 to your computer and use it in GitHub Desktop.
Will return true or false if a table exists or not $db is a mysqli db connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function table_exists($table) { | |
global $db; | |
$sql = "SHOW TABLES LIKE '$table' "; | |
$result = $db->query($sql); | |
$num = 0; | |
$num = mysqli_num_rows($result); | |
if($num > 0) { | |
return true; | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment