Opened 13 years ago
Closed 13 years ago
#12773 closed defect (bug) (worksforme)
dbDelta fails to create multiple tables with IF NOT EXISTS
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9.2 |
Component: | General | Keywords: | dbDelta, wpdb, create table |
Focuses: | Cc: |
Description
using the dbDelta function with a query containing multiple CREATE TABLE will fail to create all but the last table: e.g
dbDelta( CREATE TABLE IF NOT EXISTS `A` (...); CREATE TABLE IF NOT EXISTS `B` (...); )
will create only the B table
It seems that the function doesn't parse the SQL correctly and attempts to create a table called 'IF'
Change History (1)
Note: See
TracTickets for help on using
tickets.
dbDelta takes a standard CREATE TABLE definition and compares it with the schema.
If the table, field, or index doesn't exist, it adds it, or the reverse, if a field or index is removed, it removes it.
Additionally, the table definition must be written to very careful specifications (consult wp-admin/includes/schema.php's table definitions as an example) for dbDelta to work completely.