function processFunctions() { global $ax, $repair, $compact, $backup, $restore, $events, $delevt, $fromD, $tillD; echo "<table><tr><td>\n"; if ($repair) { checkDb(); } if ($compact) { compactTables(); } if ($backup) { backupTables(); } if ($restore) { restoreTables(); } if ($events) { processEvents(); } echo "</td></tr></table>\n"; echo "<form action='index.php?lc' method='post'>\n\t\t<input type='hidden' name='repair' id='repair' value='{$repair}'>\n\t\t<input type='hidden' name='compact' id='compact' value='{$compact}'>\n\t\t<input type='hidden' name='backup' id='backup' value='{$backup}'>\n\t\t<input type='hidden' name='restore' id='restore' value='{$restore}'>\n\t\t<input type='hidden' name='events' id='events' value='{$events}'>\n\t\t<input type='hidden' name='delevt' id='delevt' value='{$delevt}'>\n\t\t<input type='hidden' name='fromD' id='fromD' value='" . IDtoDD($fromD) . "'>\n\t\t<input type='hidden' name='tillD' id='tillD' value='" . IDtoDD($tillD) . "'>\n\t\t<input class='noPrint' type='submit' name='back' value=\"{$ax['back']}\">\n\t</form>\n"; }
} else { echo ";\n"; } } while ($row); } } ///////////////////////////////////////// // check if this script is running from cli - exit otherwise if (substr(php_sapi_name(), 0, 3) != 'cli') { echo "ERROR: This script should be called by CLI!"; exit; } // to dump current schema uncomment this line // DumpSchemaJson($currSchema, "./currentSchema.json"); //check DB connection checkDb(); //read pattern file $patternSchema = ReadJsonSchema($exportPatternFile); //get DB schema from DB $currSchema = GetCurrentSchemaObj($dbName); if ($currSchema === NULL) { error("Can't read schema!"); exit; } //check if the pattern is compatible with current schema //if not pattern schema needs to be updated debug(title("Compare schemas started")); CompareSchemas($patternSchema, $currSchema); debug(title("Compare schemas completed")); //dump DB structure if needed if (DB_STRUCT_DUMP) {
function processSetup() { global $i, $c; $i = 0; $c = 0; // Database Connectivity Checking if ($error = checkDb($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Connected to Database'; $i++; $c++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Connecting to Database :' . mysql_error(); $i++; } // Database Name Check if ($error = selectDb($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Selected Database "' . $_POST['db_name'] . '"'; $i++; $c++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Selecting Database :' . mysql_error(); $i++; } // Creating Tables if ($error = createTables($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Tables Created Successfully'; $i++; $c++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Tables :' . mysql_error(); $i++; } // Sample Questions if ($_POST['sample_qstn'] == 'yes') { if ($error = insertSQstn($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Sample Questions inserted Successfully'; $i++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Inserting Sample Questions :' . mysql_error(); $i++; } } // Creating Admin Account if ($error = createAdmin($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Admin Account Created Successfully'; $i++; $c++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Admin Account :' . mysql_error(); $i++; } // Creating Mail Settings if ($error = addMailSett($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Mail Settings Updated Successfully'; $i++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Updating Mail Settings :' . mysql_error(); $i++; } // Create Config File if ($c >= 4) { if ($error = createConfig($_POST)) { $_SESSION['ERROR'][$i]['type'] = 'Done'; $_SESSION['ERROR'][$i]['reason'] = 'Config File Created Successfully'; $mail = new PHPMailer(); PQmail($mail, $_POST); $i++; $c++; } else { $_SESSION['ERROR'][$i]['type'] = 'Error'; $_SESSION['ERROR'][$i]['reason'] = 'Error Creating Config File '; $i++; } } }
{ $db = Database::getInstance(); if (($file_handle = fopen($file, "r")) !== FALSE) { fgetcsv($file_handle); // skip the first line while (!feof($file_handle)) { $line = fgetcsv($file_handle, 1024, ','); $db->query("\n INSERT INTO postal_codes (postal, city, region_name, region_iso, latitude, longitude)\n VALUES (:postal, :city, :region_name, :region_iso, :latitude, :longitude)\n "); $db->bind(':postal', $line[0]); $db->bind(':city', $line[1]); $db->bind(':region_name', $line[2]); $db->bind(':region_iso', $line[3]); $db->bind(':latitude', $line[4]); $db->bind(':longitude', $line[5]); $db->execute(); } } } function checkDb() { $db = Database::getInstance(); $db->query("SELECT * FROM postal_codes"); return $db->resultset(); } $csvFile = '../IMPORT_TEST.csv'; // target CSV file // Check to see if database postal_codes table is not empty if (!checkDb()) { // If database is empty insert CSV file importCSV($csvFile); }