A good way of organizing/controling the initializingstage is to use a 2-
dimensional array filled with your
SQL-statementstrings. Each category has its own array. Now you can loop through
the categories ,
execute the statements and see whether they succeeded or not. It can be done
this way:
$actions = array (
/************** DROP TABLES ********************/
// Delete all the tables. This also
// deletes all the indices and sequences.
array(
"DROP TABLE $First_table",
"DROP TABLE $Sec_table",
"DROP TABLE $Third_table",
"DROP TABLE $Autoid_table"
),
/************ CREATE INDICES & SEQUENCE ***************/
array(
"CREATE UNIQUE INDEX index1 ON $First_table(UID)",
"CREATE INDEX index2 ON $First_table(F_name)",
"CREATE INDEX index3 ON $First_table(L_name)",
"CREATE UNIQUE INDEX index4 ON $Sec_table(Idnr)",
"CREATE INDEX index5 ON $Sec_table(Date_out)",
"CREATE INDEX index6 ON $Third_table(id,pw)",
"create sequence on $Autoid_table step 1 value 0"
)
); // end of 2-dimensional array
/*************** EXECUTE QUERIES **********/
for ($counter = 0; $counter <= 2;$counter++) {
$number = count($actions[$counter]); // count number of array-elements
for ($teller = 0; $teller < $number ;$teller++) {
echo $actions[$counter][$teller];
$result = msql($Dbname, $actions[$counter][$teller]);
if ($result > 0){
ECHO " = Succesfull.<br>";
} else {
ECHO " = Unsuccesfull.<br>";
}
}
}
?>
The "droppings" will cause warningmessages the first time you execute them
because there were no
tables to drop since you haven't created them yet.