How do I edit MySQL table column properties with PHP?
I need to edit a field type in a MySQL table. Currently I have this one column set as VARCHAR that I need to change to an INT. 开发者_开发问答 The catch is that I do not have access to the control panel so I cannot simply flip the switch. How do I go about making this edit with PHP?
Just execute an ALTER TABLE statement
ALTER TABLE tablename MODIFY columnname INT;
In PHP:
$result = mysql_query("ALTER TABLE tablename MODIFY columnname INT;");
If you require extra attributes on that column, such as NOT NULL, PRIMARY KEY, or others, be sure to include them in the ALTER statement, just after the data type INT.
加载中,请稍侯......
精彩评论