Brent Shepherd
Member
Posted 2 years ago #
Hello all,
I need to create a table for my plugin.
I found two methods to create a table:
- dbDelta: as used in the Creating Tables with Plugins page on the codex
- maybe_create_table($table_name, $create_ddl): as found in /admin/install-helper.php and used in many plugins
Is one of these methods better than the other? If so, why?
Thanks in advance. :)
Brent
Brent Shepherd
Member
Posted 2 years ago #
FYI for anyone who may be wondering the same thing.
dbDelta is the better method.
dbDelta provides upgrade functionality. You could use maybe_create_table, but if you change the structure of your table in a later release. It won't upgrade properly.
thank you brentes
Do you mean I don't need to check whether a table is exists or not if using dBdelta?