<?php

$database_name = '';
$r = dbquery("SHOW TABLES FROM $database_name");
$query = '';
while ($d = mysql_fetch_row($r)) {
   $table_name = $d[0];
   $result = dbquery("SHOW FIELDS FROM $table_name");
   $query .= "ALTER TABLE $table_name ";
   while ($d1 = mysql_fetch_row($result)) {
      if (eregi('bigint',$d1[1])) $query .= "MODIFY ".$d1[0]." SMALLINT (5) UNSIGNED NOT NULL, ";
   }
   $query = substr($query,0,strlen($query)-2);
   $query .= ";\r\n";
}

$lines = explode("\r\n",$query);
for ($i = 0; $i < count($lines); $i++) {
   $line = trim($lines[$i]);
   if (eregi('MODIFY',$line)) $result = dbquery($line);
}

?>