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

mysql_testa_view.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);

while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
  $sql = "select * from ".$row['TABLE_SCHEMA'].".".$row['TABLE_NAME']." limit 1";
  echo $sql."\n";
  if(!mysqli_query($con,$sql)){
    $msgErro[] = mysqli_error($con);
  }
}

system('clear');
if(empty($msgErro)){
  echo "\n\n\nTudo certo!\n\n\n";
}else{
  echo "\n\n\nTabelas com erros:\n";
  print_r($msgErro);
}

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