Opened 16 years ago
Closed 16 years ago
#8768 closed defect (bug) (duplicate)
dbDelta() queries fails with the ` char
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.7 |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (4)
#1
@
16 years ago
- Version set to 2.7
I'm not sure that I get the point. Why not just code the plugin as in example 2 if that already works?...
Note: See
TracTickets for help on using
tickets.
Patch for wp-admin/includes/upgrade.php