Support » Plugins » dbDelta vs maybe_create_table()

  • Hello all,

    I need to create a table for my plugin.

    I found two methods to create a table:

    1. dbDelta: as used in the Creating Tables with Plugins page on the codex
    2. 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Brent

    (@brentes)

    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘dbDelta vs maybe_create_table()’ is closed to new replies.