WordPress.org

Ready to get started?Download WordPress

Forums

dbDelta vs maybe_create_table() (3 posts)

  1. Brent
    Member
    Posted 5 years ago #

    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

  2. Brent
    Member
    Posted 4 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.

  3. takien
    Member
    Posted 4 years ago #

    thank you brentes

    Do you mean I don't need to check whether a table is exists or not if using dBdelta?

Topic Closed

This topic has been closed to new replies.

About this Topic