Forums

Can't get WP to query new table in database (4 posts)

  1. digitalmcgrath.com
    Member
    Posted 2 years ago #

    Hello all,

    I imported a new table into my WP database. I renamed the table to include the "wp_" prefix, but when I try and query that table, I don't get any results or any errors. Here is the code I am playing with:

    global $wpdb;
    
    $facility_count = $wpdb->get_var("SELECT COUNT(id) FROM $wpdb->facilities;");?>
    <p><?php echo 'facility count is ' . $facility_count;?></p>

    Is there some other trick besides renaming the table to include the "wp_" prefix in order to use it?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Use wp_facilities instead of $wpdb->facilities

  3. digitalmcgrath.com
    Member
    Posted 2 years ago #

    Brilliant!!!

    Thanks!

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    I believe there is a way to register your tables so you can use $wpdb->facilities but not too sure what that is...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags