Drop into the Deep End
by Remy Porter
in CodeSOD
on 2020-12-15
Would you like to guarantee your project ends up on this site? Antoon's employer has a surefire technique. First, hire a freshly graduated architect with no programming experience. Second, chuck them into a project in a programming language they don't know. Third, give them absolutely no supervision and no guidance or support, and watch what happens.
<?php
function copy_tables($table1, $table2, $copy, $size, $link, $action, $testOper)
{
global $link;
global $result;
global $timezone;
$result[1] = $copy;
if ($size = 'EXIST')
{
$queryz0 = "drop table if exists $table1";
$requestz0 = db_query($queryz0, $link) or error_log("copy_tables *** $table1 : Error in the execution of request z0", db_error() , $action, $testOper) . "\n";
if ($result[1] == "error")
{
exit;
}
$queryz1 = "create table $table1 LIKE $table2";
$requestz1 = db_query($queryz1, $link) or error_log("copy_tables *** $table1 : Error in the execution of request z1", db_error() , $action, $testOper) . "\n";
if ($result[1] == "error")
{
exit;
}
}
elseif ($size = 'NOTEXIST')
{
$queryz2 = "create table if not exists $table1 LIKE $table2";
$requestz2 = db_query($queryz2, $link) or error_log("copy_tables *** $table1 : Error in the execution of request z2", db_error() , $action, $testOper) . "\n";
if ($result[1] == "error")
{
exit;
}
}
$queryz3 = "insert $table1 select * from $table2";
$requestz3 = db_query($queryz3, $link) or error_log("copy_tables *** $table1 : Error in the execution of request z3", db_error() , $action, $testOper) . "\n";
if ($result[1] == "error")
{
exit;
}
}
?>