44 lines
857 B
PHP
44 lines
857 B
PHP
<?php
|
|
|
|
include "db.php";
|
|
|
|
$tableName = "schools";
|
|
if ($argc > 1) $tableName = $argv[1];
|
|
else {
|
|
$table = readline("Table (schools): ");
|
|
if (strlen(trim($table))) $tableName = $table;
|
|
}
|
|
|
|
|
|
echo("\n");
|
|
|
|
$query = "SHOW columns FROM $tableName";
|
|
$results = db_query($query);
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$field = $row['Field'];
|
|
$type = $row['Type'];
|
|
|
|
switch ($type) {
|
|
case 'int':
|
|
case 'int unsigned':
|
|
case 'smallint':
|
|
case 'smallint unsigned':
|
|
case 'bigint':
|
|
case 'bigint unsigned':
|
|
echo('if (!isset($' . $field . ')) $' . $field . " = 0;\n");
|
|
break;
|
|
|
|
case 'decimal(12,2)':
|
|
echo('if (!isset($' . $field . ')) $' . $field . " = 0.0;\n");
|
|
break;
|
|
|
|
default:
|
|
echo('if (!isset($' . $field . ')) $' . $field . " = '';\n");
|
|
}
|
|
}
|
|
|
|
echo("\n");
|
|
|
|
?>
|