WordPress.org

Ready to get started?Download WordPress

Forums

How To Check If Table Exists...? (5 posts)

  1. thejoker101
    Member
    Posted 8 years ago #

    I'm working on a plugin and I would like to check the DB to see if a column already exists or not. I can't seem to find any way of doing that. Perhaps I'm not looking in the right spot?

  2. masquerade
    Member
    Posted 8 years ago #

    Why would you need to see if a column exists? If you're trying to add a column if it doesn't exist, use the dbDelta function in upgrade-functions.php

  3. Joshua Sigar
    Member
    Posted 8 years ago #

  4. thejoker101
    Member
    Posted 8 years ago #

    Duh. Sometimes my brain just don't work. Perhaps because it's monday. Thanks again.

  5. thejoker101
    Member
    Posted 8 years ago #

    OK, I'm finally getting back to working on my plugin and I have a problem.

    I'm creating a new column in the wp_posts table. The proper way is to use the dbdelta() function. The dbdelta function is supposed to take the new table structure, in sql, as it's input. However, when I do this, I get an error saying the table was already created. What's the deal?

Topic Closed

This topic has been closed to new replies.

About this Topic