HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Trying to create a Column Type of ENUM for my plugin
I am trying to create an ENUM column with the values Cash or Tournament
Gdn::structure() ->table('Discussion') ->column('TestGameType', 'ENUM('Cash','Tournament')', true) ->set(false,false)
It throws an error on the word Cash when enabling the plugin how would I create an enum field?
0
Comments
IIRC you just have to pass in the array of values. But you can look into the dashboard structure.php file and the Gender field of the user table
NM figured it out
hehe we posted at the same time :) Thanks it is a passed array!
By the way : if you add info to the discussion table that doesn't need to be included in the where part of a sql query, you should consider using the Attributes column for it.
whats an attribute column ?? Now i am all curious
BTW have a look at your plugin http://pf.main.nu you can do a year and month view... day view coming but its as easy as just showing all discussion on that date
Vanilla uses a column called "Attributes" in several tables, most interesting tables are User, Discussion and Comment. That column is used to store "misc" information in an array. The Gdn_Model class (filename is class.model.php) has some helper methods, from which only the
saveToSerializedColumn()
method might be of interest.Here is a snippet showing how to handle that column:
(Create yourself a test plugin where you attach that method or attach it to any other plugin you ar working on and afterwards, logged in as the admin, open yourforum.com/plugin/abracadabra)
Here are two insightful discussions which at least note that column shortly:
https://open.vanillaforums.com/discussion/comment/232157/#Comment_232157
https://open.vanillaforums.com/discussion/comment/207196#Comment_207196
As you can see, adding more and more columns to the above mentioned tables isn't the best practice. If you can avoid it by storing some "meta information" in the Attributes column, you should definitly do that.