Has anyone out there tried to create an ENUM field in the database for his module? I'm running into problems with ADOdb not picking up my ENUM values when I run CreateTableSQL(). For instance:
"pn_status enum ('active','inactive') NOTNULL DEFAULT 'active'"
...when fed to CreateTableSQL(), becomes...
"pn_status ENUM NOT NULL DEFAULT 'active'"
As you can see, it didn't correctly interpret the enum values. I'm fairly sure this is an issue with ADOdb 4.991 (included with Zikula 1.1.1); has anyone found a workaround? I suppose I could just create them as varchar fields and manually convert them to enum fields post-install, but that seems very kludgy.
Thanks,
Ben B.
--
--
Ben Birney
http://www.tilsontech.com/
http://www.sophiasfall.com/
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- rgasch created topic »Using PageUtil::addVar() to load script code« 11:48 AM
- michiel responded to »password problem« 10:01 AM
- mazdev responded to »Hide "Register new account" and change template to 3 col« 07:50 AM
- mesteele101 created topic »Zikula 1.3.3 - Site Search 1.5.2 - Unable to turn off plug-ins« 07:48 AM
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Creating an ENUM field using ADOdb->CreateTableSQL
-
- Rank: Registered User
- Registered: Apr 23, 2004
- Last visit: Feb 07, 2010
- Posts: 30
-
- Rank: Team Member
- Registered: Mar 15, 2004
- Last visit: May 26, 2010
- Posts: 112
-
- Rank: Registered User
- Registered: Apr 23, 2004
- Last visit: Feb 07, 2010
- Posts: 30
I never found one, AKA. I ended up altering my schema to use a regular VARCHAR type instead of ENUM, and restricting the values programmatically.
--
--
Ben Birney
http://www.tilsontech.com/
http://www.sophiasfall.com/ -
- Rank: Team Member
- Registered: Mar 15, 2004
- Last visit: May 26, 2010
- Posts: 112
I filed a bug for it here:
http://code.zikula.org/core/ticket/1794
In the meantime, you can try this tmp fix I have:
in pntables.php, code as usual.
in pninit.php, instead of using:
DBUtil::createTable('Example');
Use this:
$SQL = "CREATE TABLE IF NOT EXISTS `zk_Example` (
`pn_id` int(11) NOT NULL auto_increment,
`pn_illustration_alignment` enum('yes','no') collate utf8_unicode_ci NOT NULL default 'yes',
`pn_cr_date` datetime NOT NULL default '1970-01-01 00:00:00',
`pn_cr_uid` int(11) NOT NULL default '0',
`pn_lu_date` datetime NOT NULL default '1970-01-01 00:00:00',
`pn_lu_uid` int(11) NOT NULL default '0',
PRIMARY KEY (`pn_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ";
DBUtil::executeSQL($SQL); -
- Rank: Registered User
- Registered: Apr 23, 2004
- Last visit: Feb 07, 2010
- Posts: 30
Hey, there you go. Good workaround.
--
--
Ben Birney
http://www.tilsontech.com/
http://www.sophiasfall.com/ -
- Rank: Team Member
- Registered: Feb 27, 2005
- Last visit: Apr 12, 2010
- Posts: 665
IIRC ANSI SQL has no support for the 'ENUM' datatype. So this script would make your module MYSQL only (or at least SQL-dialect specific). In this case, if possible for your application of course, I would choose to store as boolean, and define constants in your module where 0 = INACTIVE and 1 = ACTIVE.
--
-- Teb
-- Dutch Zikula Community
Support questions in a Personal Message will be ignored. Use the forums at all times! -
- Rank: Team Member
- Registered: Mar 15, 2004
- Last visit: May 26, 2010
- Posts: 112
Yes, I am already aware that ENUM is proprietary to MySQL. For my purposes, this type suffices.
Nevertheless, thanks Teb for pointing that out, in case anyone else might be interested in using ENUM.
- Moderated by:
- Support
