一般PHP系统的网站,安装时往数据库里建表如何操作
一般PHP系统的网站,安装时往数据库里建表怎么操作?
比如我已经有了123.sql文件
现在想弄一个安装页面,点提交就将123.sql导入到指定的表中
代码怎么写?
------解决方案--------------------
query(文件内容);
------解决方案--------------------
- PHP code
<?phpif (...){//判断提交 //连接数据库... $path="./123.sql";//123.sql相对该php文件地址 mysql_query("source $path");}<br /><font color="#e78608">------解决方案--------------------</font><br>
------解决方案--------------------
真的可以这样做吗?
不要自欺欺人了
------解决方案--------------------
找一个安装程序的开源项目,安装一下不就知道了。
dedecms的,一看就明了
大概如下
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(30) NOT NULL default '',
`userip` char(15) 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(30) NOT NULL default '',
`userip` char(15) 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(11) NOT NULL default '0',
`typeid` int(11) 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(10) unsigned NOT NULL default '0',
`title` varchar(60) NOT NULL default '',
`litpic` varchar(60) NOT NULL default '',
`userip` varchar(15) NOT NULL default ' ',
`senddate` int(11) NOT NULL default '0',
`flag` set('c','h','p','f','s','j','a','b') default NULL,
`lastpost` int(10) 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(11) NOT NULL default '0',
`tel` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`address` varchar(100) NOT NULL default '',
`linkman` varchar(50) 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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The difference between null and NULL in C language is: null is a macro definition in C language, usually used to represent a null pointer, which can be used to initialize pointer variables, or to determine whether the pointer is null in a conditional statement; NULL is a macro definition in C language A predefined constant in , usually used to represent a null value, used to represent a null pointer, null pointer array or null structure pointer.

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

In JavaScript, both undefined and null represent the concept of "nothing": 1. undefined represents an uninitialized variable or a non-existent property. When a variable is declared but no value is assigned to it, the value of the variable is undefined , when accessing properties that do not exist in the object, the returned value is also undefined; 2. null represents an empty object reference. In some cases, the object reference can be set to null to release the memory it occupies.

ReactQuery database plug-in: Methods to implement data import and export, specific code examples are required. With the widespread application of ReactQuery in front-end development, more and more developers are beginning to use it to manage data. In actual development, we often need to export data to local files or import data from local files into the database. In order to implement these functions more conveniently, you can use the ReactQuery database plug-in. The ReactQuery database plugin provides a series of methods

Both null and undefined indicate a lack of value or an undefined state. Depending on the usage scenario, there are some guiding principles for choosing to use null or undefined: 1. When you need to clearly indicate that a variable is empty or invalid, you can use null; 2. When a variable has been declared but not yet assigned a value, it will be set to undefined by default; 3. When you need to check whether a variable is empty or undefined, use the strict equality operator "===" to determine whether the variable is null or undefined. .

The difference between null and undefined is: 1. Semantic meaning; 2. Usage scenarios; 3. Comparison with other values; 4. Relationship with global variables; 5. Relationship with function parameters; 6. Nullability check; 7. Performance considerations; 8. Performance in JSON serialization; 9. Relationship with types. Detailed introduction: 1. Semantic meaning, null usually means knowing that this variable will not have any valid object value, while undefined usually means that the variable has not been assigned a value, or the object does not have this attribute; 2. Usage scenarios, etc.

Steps to configure default gateway: 1. Open the control panel; 2. Select Network and Internet; 3. Configure network connection; 4. Configure IP address; 5. Configure DNS server address; 6. Confirm the configuration; 7. Restart the network device. Detailed introduction: 1. Open the Control Panel, in Windows system, click the Start menu, select "Control Panel"; 2. Select Network and Internet, in the Control Panel, select "Network and Internet"; 3. Configure network connections, etc. .

Steps to configure default gateway: 1. Determine the IP address of the router; 2. Open the network configuration interface of the computer; 3. Configure network connection; 4. Configure IPv4 settings; 5. Enter the IP address and subnet mask; 6. Configure the default gateway ;7. Configure DNS server; 8. Save settings. Detailed introduction: 1. Determine the router's IP address. The default gateway address is usually the router's IP address. You can find the router's IP address on the back of the router or in the user manual; 2. Open the computer's network configuration, etc.
