Changeset 13229 for trunk/wp-includes/wp-db.php
- Timestamp:
- 02/19/2010 07:57:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-db.php
r13209 r13229 138 138 var $blogid = 0; 139 139 var $siteid = 0; 140 var $blogs;141 var $signups;142 var $site;143 var $sitemeta;144 var $sitecategories;145 var $global_tables = array('blogs', 'signups', 'site', 'sitemeta', 'users', 'usermeta', 'sitecategories', 'registration_log', 'blog_versions');146 140 147 141 /** … … 164 158 165 159 /** 166 * WordPress C ategories table160 * WordPress Comments table 167 161 * 168 162 * @since 1.5.0 … … 170 164 * @var string 171 165 */ 172 var $c ategories;173 174 /** 175 * WordPress Post to Categorytable166 var $comments; 167 168 /** 169 * WordPress Links table 176 170 * 177 171 * @since 1.5.0 … … 179 173 * @var string 180 174 */ 181 var $ post2cat;182 183 /** 184 * WordPress Comments table175 var $links; 176 177 /** 178 * WordPress Options table 185 179 * 186 180 * @since 1.5.0 … … 188 182 * @var string 189 183 */ 190 var $comments;191 192 /**193 * WordPress Links table194 *195 * @since 1.5.0196 * @access public197 * @var string198 */199 var $links;200 201 /**202 * WordPress Options table203 *204 * @since 1.5.0205 * @access public206 * @var string207 */208 184 var $options; 209 185 … … 263 239 264 240 /** 265 * List of WordPress tables241 * List of WordPress per-blog tables 266 242 * 267 243 * @since {@internal Version Unknown}} 268 244 * @access private 245 * @see wpdb::tables() 269 246 * @var array 270 247 */ 271 var $tables = array( 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',272 'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta');248 var $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta', 249 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta' ); 273 250 274 251 /** … … 277 254 * @since 2.9.0 278 255 * @access private 256 * @see wpdb::tables() 279 257 * @var array 280 258 */ 281 var $old_tables = array('categories', 'post2cat', 'link2cat'); 282 283 284 /** 285 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. 259 var $old_tables = array( 'categories', 'post2cat', 'link2cat' ); 260 261 /** 262 * Multisite Blogs table 263 * 264 * @since 3.0.0 265 * @access public 266 * @var string 267 */ 268 var $blogs; 269 270 /** 271 * Multisite Signups table 272 * 273 * @since 3.0.0 274 * @access public 275 * @var string 276 */ 277 var $signups; 278 279 /** 280 * Multisite Sites table 281 * 282 * @since 3.0.0 283 * @access public 284 * @var string 285 */ 286 var $site; 287 288 /** 289 * Multisite Site Metadata table 290 * 291 * @since 3.0.0 292 * @access public 293 * @var string 294 */ 295 var $sitemeta; 296 297 /** 298 * Multisite Sitewide Terms table 299 * 300 * @since 3.0.0 301 * @access public 302 * @var string 303 */ 304 var $sitecategories; 305 306 /** 307 * Multisite Registration Log table 308 * 309 * @since 3.0.0 310 * @access public 311 * @var string 312 */ 313 var $registration_log; 314 315 /** 316 * Multisite Blog Versions table 317 * 318 * @since 3.0.0 319 * @access public 320 * @var string 321 */ 322 var $blog_versions; 323 324 /** 325 * List of Multisite global tables 326 * 327 * @since 3.0.0 328 * @access private 329 * @see wpdb::tables() 330 * @var array 331 */ 332 var $ms_tables = array( 'blogs', 'signups', 'site', 'sitemeta', 333 'sitecategories', 'registration_log', 'blog_versions' ); 334 335 /** 336 * List of WordPress global tables 337 * 338 * @since 3.0.0 339 * @access private 340 * @see wpdb::tables() 341 * @var array 342 */ 343 var $global_tables = array( 'users', 'usermeta' ); 344 345 /** 346 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. 286 347 * 287 348 * Keys are colmn names, values are format types: 'ID' => '%d' … … 291 352 * @see wpdb:insert() 292 353 * @see wpdb:update() 354 * @see wp_set_wpdb_vars() 293 355 * @access public 294 356 * @var array … … 440 502 * @return string|WP_Error Old prefix or WP_Error on error 441 503 */ 442 function set_prefix( $prefix) {504 function set_prefix( $prefix ) { 443 505 444 506 if ( preg_match('|[^a-z0-9_]|i', $prefix) ) … … 453 515 $old_prefix = $this->base_prefix; 454 516 $this->base_prefix = $prefix; 455 foreach ( $this-> global_tablesas $table )517 foreach ( $this->tables( 'global' ) as $table ) 456 518 $this->$table = $prefix . $table; 457 519 458 if ( defined('VHOST') && empty( $this->blogid) )520 if ( defined('VHOST') && empty( $this->blogid ) ) 459 521 return $old_prefix; 460 522 461 523 $this->prefix = $this->get_blog_prefix( $this->blogid ); 462 524 463 foreach ( (array) $this->tables as $table ) 525 foreach ( (array) $this->tables( 'blog' ) as $table ) 526 $this->$table = $this->prefix . $table; 527 528 foreach ( (array) $this->tables( 'old' ) as $table ) 464 529 $this->$table = $this->prefix . $table; 465 530 … … 482 547 $this->prefix = $this->get_blog_prefix( $this->blogid ); 483 548 484 foreach ( $this->tables as $table ) 549 foreach ( $this->tables( 'blog' ) as $table ) 550 $this->$table = $this->prefix . $table; 551 552 foreach ( $this->tables( 'old' ) as $table ) 485 553 $this->$table = $this->prefix . $table; 486 554 … … 497 565 return $this->base_prefix; 498 566 } 567 } 568 569 /** 570 * Returns an array of WordPress tables. 571 * 572 * @since 3.0.0 573 * @uses wpdb::tables 574 * @uses wpdb::old_tables 575 * @uses wpdb::global_tables 576 * @uses is_multisite() 577 * 578 * @param string $scope Can be all, global, blog, or old tables. Default all. 579 * All returns all global tables and the blog tables for the queried blog. 580 * @param bool $prefix Whether to include the blog prefix. Default false. 581 * @param int $blog_id The blog_id to prefix. Defaults to main blog. 582 * @return array Table names. 583 */ 584 function tables( $scope = 'all', $prefix = false, $blog_id = 0 ) { 585 switch ( $scope ) { 586 case 'old' : 587 $tables = $this->old_tables; 588 break; 589 case 'blog' : 590 $tables = $this->tables; 591 break; 592 case 'global' : 593 $tables = array_merge( $this->global_tables, $this->ms_tables ); 594 break; 595 case 'all' : 596 $tables = array_merge( $this->global_tables, $this->tables ); 597 if ( is_multisite() ) 598 $tables = array_merge( $tables, $this->ms_tables ); 599 break; 600 } 601 602 if ( $prefix ) { 603 $prefix = $this->get_blog_prefix( $blog_id ); 604 foreach ( $tables as &$table ) { 605 $table = $prefix . $table; 606 } 607 } 608 609 return $tables; 499 610 } 500 611
Note: See TracChangeset
for help on using the changeset viewer.