[wp-trac] [WordPress Trac] #8768: dbDelta() queries fails with the
` char
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 31 15:29:47 GMT 2008
#8768: dbDelta() queries fails with the ` char
--------------------------+-------------------------------------------------
Reporter: binnyva | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.8
Component: Plugins | Version:
Severity: normal | Keywords: has-patch
--------------------------+-------------------------------------------------
If I use the ` while creating a SQL query in a WP Plugin(if the SQL is
created using phpMyAdmin export feature, it will have the ` quoting),
dbDelta will not work. An example...
{{{
$sql = "CREATE TABLE `{$wpdb->prefix}eventr_event_attendee` (
`event_ID` int(11) unsigned NOT NULL,
`attendee_ID` int(11) unsigned NOT NULL,
`added_on` datetime NOT NULL,
`guests` int(2) NOT NULL default '0',
KEY `event_ID` (`event_ID`,`attendee_ID`)
);";
dbDelta($sql);
}}}
Will '''not''' work - but this will...
{{{
$sql = "CREATE TABLE {$wpdb->prefix}eventr_event_attendee (
event_ID int(11) unsigned NOT NULL,
attendee_ID int(11) unsigned NOT NULL,
added_on datetime NOT NULL,
guests int(2) NOT NULL default '0',
KEY event_ID (event_ID,attendee_ID)
);";
dbDelta($sql);
}}}
The easiest way to fix this is to replace all ` chars with an empty string
in the dbDelta() function. But I think it is a bit too 'hacky'. I have
created an alternative solution - the patch is attached.
I have tested it with WordPress 2.7 - with one of my plugins.
--
Ticket URL: <http://trac.wordpress.org/ticket/8768>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list