/** * 主体思想必须光辉伟大! * * @return void **/ function run() { //删除文件 deletedir(); //删除数据库 deleteDB(); }
<?php require_once '../config.php'; checkAjax(); $return_data = array('status' => 0); $id = secure_data($_POST['id']); $table = secure_data($_POST['tbl']); $allowed_tables = array('courses', 'course_sections'); if ($id && $table && in_array($table, $allowed_tables)) { deleteDB($table, $id); $return_data['status'] = 1; $return_data['message'] = 'Record deleted successfully.'; } echo json_encode($return_data); exit;
function get_adminpageDeletePodcast($delete_id, $admin_url) { //lese DB aus $db = schalterDB(true); //lösche einen Eintrag deleteDB($db, $delete_id); //mache weiterleitung header("location: " . $admin_url . "?intern=updatepage"); }
<?php require_once 'config.php'; checkAjax(); $return_data = array('status' => 0); $id = secure_data($_POST['id']); if ($id) { deleteDB('users', $id); $return_data['status'] = 1; $return_data['message'] = 'User deleted successfully.'; } echo json_encode($return_data); exit;
<?php require_once '../config.php'; checkAjax(); $return_data = array('status' => 0); $id = secure_data($_POST['section_id']); if ($id) { deleteDB('course_sections', $id); $return_data['id'] = $id; $return_data['status'] = 1; $return_data['message'] = 'Record deleted successfully.'; } echo json_encode($return_data); exit;
<?php define('SQL_HOST', 'localhost'); define('SQL_USER', 'root'); define('SQL_PASS', 'pasok'); define('SQL_DB', 'todo_db'); $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die('Could not connect to the database; ' . mysql_error()); if (isset($_GET['action'])) { echo 'Processing action: ' . $_GET['action']; echo '</br>'; switch ($_GET['action']) { case 'create': createDB(SQL_DB, $conn); break; case 'delete': deleteDB(SQL_DB, $conn); break; case 'tables': createTables(SQL_DB, $conn); break; case 'drop': dropTables(SQL_DB, $conn); break; case 'data': insertTestDataSet(SQL_DB, $conn); break; } } function createDB($dbName, $conn) { $sql = <<<EOS
echo $importResult; } // display the tables on screen so we can see they were dumped if ($tables = getTableList($connection, $config["db"]["name"])) { foreach ($tables as $id => $table) { printTable($connection, $table); } } else { echo "<br><br>No tables found.<br><br>"; } } else { echo "Error selecting database: " . mysql_error(); } } else { // drop the database deleteDB($connection, $config["db"]["name"]); } // disconnect from db server mysql_close($connection); // dump the output buffer $buffer = ob_get_contents(); ob_end_clean(); ?> <h1>MySQL Helper</h1> <p>This script is intended as a package of basic MySQL database functions. When you load this page, it will cycle through and show one of these two alternating states:</p> <ul> <li>Database roundtrip: Show the existing server environment, create a new database from the contents of <code>db/schema.php</code>, populate it with example data from <code>db/data.php</code>, export it to a flat file, delete all tables, then re-import from the generated flat file.</li> <li>Database dump: throwing out the previous database and showing nothing.</li> </ul>