dtyyrt4545 2010-12-02 06:03
浏览 36
已采纳

使用PHP通过HTML表单更改MySQL表上的ENUM列是不是一个坏主意?

Suppose that I have an enum column on a table and I want users to be able to expand the number of values it contains via an HTML form submission on the front end by using PHP to run a query that alters the table to contain more enum values for that column .

  • Is it a bad idea to run queries very often that will alter the a table structure?
  • Is there a security issue inherent that I can't see?
  • If I sanitize user input before altering the table with the new values is that sufficient?
  • 写回答

2条回答 默认 最新

  • dongshanxun6479 2010-12-02 06:28
    关注

    As Col.Shrapnel already said, yes, it's a bad idea. Unless you're making an application specifically meant to admin a database, it's generally bad practice to allow your app to alter a database in any way with very few exceptions (so feel free to use temp tables). Doubly so in PHP. The most immediately apparent impact is if you modify any enum list value, this field in all records in the table using that old value will be erased. A choice quote from mysql manual...

    An ENUM is a string object with a value chosen from a list of permitted values 
    that are enumerated explicitly in the column specification 
    at table creation time. 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献