Forums

Creating tables from .sql on plugin activate (2 posts)

  1. rmckillen
    Member
    Posted 2 years ago #

    I have referred to http://codex.wordpress.org/Creating_Tables_with_Plugins, but it's not helping me with my issue.

    I am writing a plugin that requires the creation of numerous tables. I have an .sql file with the desired SQL, which I read into a $sql variable.

    Is there a simple way to execute all of that SQL in one shot? The $wpdb->query($sql) function trips up if there is more than one SQL query.

    If necessary, I can parse by semi-colons and loop through, executing each query individually, but that seems messy.

  2. apljdi
    Member
    Posted 2 years ago #

    You don't have to use the $wpdb object. I'd loop through if it were me, using the dbDelta function, but you don't have to.

Topic Closed

This topic has been closed to new replies.

About this Topic