General PHP System Web site, installed in the database to build a table how to operate?
Like I already have a 123.sql file.
Now you want to get an installation page, click Submit to import 123.sql into the specified table
How do you write the code?
------Solution--------------------
Query (file content);
------Solution--------------------
PHP Code
------Solution--------------------
discuss
So simple? I think too much, Khan ...
------Solution--------------------
Can you really do that?
Stop fooling yourself.
------Solution--------------------
Find an open source project to install the program, install it and know it.
Dedecms, it's clear at first sight.
Probably as follows
Sql-dftables.txt
DROP TABLE IF EXISTS ' #@__addonarticle ';
CREATE TABLE ' #@__addonarticle ' (
' Aid ' mediumint (8) unsigned not NULL default ' 0 ',
' typeID ' smallint (5) unsigned not NULL default ' 0 ',
' Body ' mediumtext,
' RedirectURL ' varchar (255) Not NULL default ' ',
' Templet ' varchar (+) not NULL default ' ',
' Userip ' char (+) not NULL default ' ',
PRIMARY KEY (' aid '),
KEY ' typeid ' (' typeid ')
) Type=myisam;
DROP TABLE IF EXISTS ' #@__addonimages ';
CREATE TABLE ' #@__addonimages ' (
' Aid ' mediumint (8) unsigned not NULL default ' 0 ',
' typeID ' smallint (5) unsigned not NULL default ' 0 ',
' Pagestyle ' smallint (6) Not NULL default ' 1 ',
' MaxWidth ' smallint (6) Not NULL default ' 600 ',
' Imgurls ' text,
' Row ' smallint (6) Not NULL default ' 0 ',
' Col ' smallint (6) Not NULL default ' 0 ',
' ISRM ' smallint (6) Not NULL default ' 0 ',
' Ddmaxwidth ' smallint (6) Not NULL default ' 200 ',
' Pagepicnum ' smallint (6) Not NULL default ' 12 ',
' Templet ' varchar (+) not NULL default ' ',
' Userip ' char (+) not NULL default ' ',
' RedirectURL ' varchar (255) Not NULL default ' ',
' Body ' mediumtext,
PRIMARY KEY (' aid '),
KEY ' Imagesmain ' (' typeid ')
) Type=myisam;
DROP TABLE IF EXISTS ' #@__addoninfos ';
CREATE TABLE ' #@__addoninfos ' (
' Aid ' int (one) not NULL default ' 0 ',
' typeID ' int (one) not NULL default ' 0 ',
' Channel ' smallint (6) Not NULL default ' 0 ',
' Arcrank ' smallint (6) Not NULL default ' 0 ',
' Mid ' mediumint (8) unsigned not NULL default ' 0 ',
' Click ' int (unsigned) not NULL default ' 0 ',
' title ' varchar not NULL default ' ',
' litpic ' varchar not NULL default ' ',
' Userip ' varchar (+) not NULL default ' ',
' Senddate ' int (one) not NULL default ' 0 ',
' Flag ' Set (' C ', ' H ', ' P ', ' f ', ' s ', ' j ', ' A ', ' B ') default NULL,
' Lastpost ' int (ten) unsigned not NULL default ' 0 ',
' Scores ' mediumint (8) Not NULL default ' 0 ',
' Goodpost ' mediumint (8) unsigned not NULL default ' 0 ',
' Badpost ' mediumint (8) unsigned not NULL default ' 0 ',
' Nativeplace ' smallint (5) unsigned not NULL default ' 0 ',
' InfoType ' smallint (5) unsigned not NULL default ' 0 ',
' Body ' mediumtext,
' Endtime ' int (one) not NULL default ' 0 ',
' Tel ' varchar (+) not NULL default ' ',
' Email ' varchar (not NULL default '),
' Address ' varchar (+) not NULL default ' ',
' Linkman ' varchar (not NULL default ' '),
PRIMARY KEY (' aid '),
KEY ' typeid ' (' typeid ', ' nativeplace ', ' InfoType '),
KEY ' channel ' (' Channel ', ' Arcrank ', ' Mid ', ' click ', ' title ', ' Litpic ', ' senddate ', ' flag ', ' Endtime ')
) Type=myisam;
。。。。
PHP Code
$query = "; $fp = fopen (dirname (__file__). ' /sql-dftables.txt ', ' R '); while (!feof ($fp)) {$line = RTrim (fgets ($FP, 1024)); if (Ereg ("; $", $line)) {$query. = $line. " \ n "; $query = Str_replace (' #@__ ', $dbprefix, $query); if ($mysqlVersion < 4.1) {$rs = mysql_query ($query, $conn); } else {if (eregi (' CREATE ', $query)) { $rs = mysql_query (eregi_replace (' Type=myisam ', $sql 4tmp, $query), $conn); } else {$rs = mysql_query ($query, $conn); }} $query = '; } else if (!ereg ("^ (//|--)", $line)) {$query. = $line; }} fclose ($FP);