Title: Associated database tables?
Last modified: August 19, 2016

---

# Associated database tables?

 *  [TrevorNet](https://wordpress.org/support/users/trevornet/)
 * (@trevornet)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/associated-database-tables/)
 * With the addition of a new network site, I noticed that additional database tables
   were added (shows you how new I am to this). How do I know which tables belong
   to the current site? I checked out get_current_site();, but it always returns
   the super-site and not the hosted network site’s information.
 * Goal/Reason: My users are able to click on a link that generates a PDF document
   on the fly. The file, rewards.php, exists outside of WordPress. I need to be 
   able to pass the networked site’s id so that rewards.php knows which table to
   pull the information from.
 * Thoughts: I know that the wp_2_* tables belongs to the first hosted site. Can
   I create the table name with ‘wp_’ . $site_id . ‘_postmeta’ with $site_id pulled
   from a native WP API call? The resulting link to rewards.php being something 
   like: rewards.php?sid=1&pid=23 (actually I would use some sort of pathetic 2-
   way encryption to at least give the impression that a person can’t simply change
   the values and get every ‘reward’ posted to each network site. rewards.php?generate
   =c2lkPTEmcGlkPTIz )
 * Note: I will worry about security and the fact that it is pretty dumb to generate
   table names from the query string later.
 * Stumped and tired of google…

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/associated-database-tables/#post-1804612)
 * hi
 * i believe $blog_id will get you what you want
 * [http://codex.wordpress.org/WPMU_Functions/get_blog_option](http://codex.wordpress.org/WPMU_Functions/get_blog_option)
 * [http://wordpress.org/support/topic/how-to-get-current-site-blog-id?replies=9](http://wordpress.org/support/topic/how-to-get-current-site-blog-id?replies=9)
 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/associated-database-tables/#post-1804624)
 * Yep. It says site in the admin area, but the tables are blogID. 🙂 (legacy terms
   😉 )

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Associated database tables?’ is closed to new replies.

## Tags

 * [database tables](https://wordpress.org/support/topic-tag/database-tables/)
 * [Site ID](https://wordpress.org/support/topic-tag/site-id/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 2 replies
 * 3 participants
 * Last reply from: [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/associated-database-tables/#post-1804624)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
