How do I create an empty table with SQL?

StAiN1337

New Member
This isn't much of an issue with MySQL per-se.The Full StoryI'm writing a very small PHP framework. It isn't like existing frameworks where they force you to use a certain methodology. It isn't either like a CMS framework. Trust me, I've seen Zend framework and I've used CMSes like Joomla and WordPress extensively, none of them come close to what I'm doing.Introducing The IssuesI'm writing the Database abstraction part. You get class methods like ::table_exists() etc.It is designed in a way that people can easily add different database classes and use them instead (eg; mysql, mssql, oracle, flatfile...).They simply need to write a class which satisfies a base abstract classes'.The Real IssueI'm writing the functionality for ::table_create(), but have one main problem: MySQL doesn't like empty tables (ie, without a column).I have several proposed fixes:
  • For each new table, create a commonly used column, such as 'id' (type=INT)
  • For each new table, create a temp column which doesn't use any space as much as possible (perhaps a boolean column?)
  • Somehow delay table creation until at least one column can be created
This approach is most certainly new, and I'd like to here some unbiased comments about it (anything on the lines of "but no one does it that way" won't do).Cheers!
 
Back
Top