Code exported to the code 2004-06-16 Click: 11
Segment Exporting Database
// $ dbname = "mytest"; $ filename = "file.sql"; MySQL_PConnect ("localhost: 3306", "root", ""); // function sqldumptable ($ table) {global $ db_site; $ TableDump = "Drop Table if EXISTS $ TABLE; / N"; $ TABLEDUMP. = "CREATE TABLE $ TABLE (/ N"; $ FIRSTFIELD = 1; $ FIELDS = mysql_query; while ($ TABLE "); Field = mysql_fetch_Array ($ FIELDS)) {if (! $ firstfield) {$ TABLEDUMP. = ", / n";} else {$ firstfield = 0;} $ TABLEDUMP. = "$ field [Field] $ FIELD [TYPE] "; if (! EMPTY ($ FIELD [" "]) {$ TABLEDUMP. =" Default '$ Field [default]' ";} f ($ field [null]! =" yes ") {$ TABLEDUMP. = "Not null";} if ($ FIELD [Extra]! = "") {$ TABLEDUMP. = "$ FIELD [Extra]";}} mysql_free_result ($ fields); $ keys = mysql_query ("Show Keys from $ "); while ($ key = mysql_fetch_array) {$ kName = $ key ['key_name']; if ($ kname! =" primary "and $ key ['Non_unique'] == 0) {$ KName = "unique | $ kname";} if (! is_ARRAY ($ index [$ kname]) {$ index [$ kname] = array ();} $ index [$ kname] [] = $ key [coluMn_name '];} mysql_free_result ($ keys); // Get Each Key Infowhile (List ($ KNAM E, $ columns) = @each ($ index)) {$ TABLEDUMP. = ", / n"; $ colnames = Implode ($ columns, ","); if ($ kname == "primary") {$ TABLEDUMP = "Primary key ($ colnames)";} else {if (Substr ($ kname, 0, 6) == "unique") {// key is unique $ kName = Substr ($ kname, 7);} $ TableDump. = "Key $ KNAME ($ colnames)";}} $ TABLEDUMP. = "/ n); / n / n"; // Get Data $ ROWS = mysql_Query ("