Sistemas‎ > ‎Linux‎ > ‎Scripts Linux‎ > ‎Mysql‎ > ‎

mysql_qtd_linha.php

<?php
$con = mysqli_connect("127.0.0.1", "root", "senha");

$sql = "SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.tables WHERE TABLE_TYPE LIKE 'VIEW'";
$result = mysqli_query($con,$sql);

system("echo '' > /tmp/mysql_qtd_registro.log");
while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
  $sql = "select count(*) quantidade from ".$row['TABLE_SCHEMA'].".".$row['TABLE_NAME']." limit 1";
  echo $sql."\n";
  $result2 = mysqli_query($con,$sql);
  if(!$result2){
    $msgErro[] = mysqli_error($con);
  }else{
    $row2 = mysqli_fetch_assoc($result2);
    system("echo '".$row['TABLE_SCHEMA'].".".$row['TABLE_NAME']." -> ".$row2['quantidade']." linhas' >> /tmp/mysql_qtd_registro.log");
  }
}

system('clear');
print_r($msgErro);

mysqli_free_result($result);
mysqli_close($con);

Comments