Created
October 17, 2013 21:02
-
-
Save deyvin/7032156 to your computer and use it in GitHub Desktop.
Dynamic sql count - all mysql database tables
This file contains hidden or 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 | |
mysql_connect("localhost", "root", "1234"); | |
$banco = 'ecommerce'; | |
$db_selected = mysql_select_db($banco); | |
$result = mysql_query('SHOW TABLES'); | |
while($row = mysql_fetch_assoc($result)) { | |
$resultTable = mysql_query("SELECT COUNT(*) FROM " . $row['Tables_in_' . $banco]); | |
$rsTable = mysql_fetch_assoc($resultTable); | |
if(strstr($row['Tables_in_' . $banco], 'carrier', true)) { | |
$carrier[] = $row['Tables_in_' . $banco] . " Registros: " . $rsTable['COUNT(*)']; | |
} | |
} | |
print_r($carrier); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment