Overview

Namespaces

  • Varunsridharan
    • WordPress

Classes

  • DB_Table
  • Overview
  • Namespace
  • Class

Class DB_Table

Class DB_Table

TheLeague\Database\Query_Builder
Extended by Varunsridharan\WordPress\DB_Table
Abstract
Namespace: Varunsridharan\WordPress
Package: Varunsridharan\WordPress
Author:

Varun Sridharan varunsridharan23@gmail.com

A base WordPress database table class, which facilitates the creation of and schema changes to individual database tables.

This class is intended to be extended for each unique database table, including global multisite tables and users tables.

It exists to make managing database tables in WordPress as easy as possible.

Extending this class comes with several automatic benefits: - Activation hook makes it great for plugins - Tables store their versions in the database independently - Tables upgrade via independent upgrade abstract methods - Multisite friendly - site tables switch on "switch_blog" action


Located at src/DB_Table.php
Methods summary
public
# __construct( )

DB_Table constructor.

DB_Table constructor.

public static Varunsridharan\WordPress\DB_Table|static
# instance( )

Returns Current Instance / create a new instance

Returns Current Instance / create a new instance

Returns

Varunsridharan\WordPress\DB_Table|static
abstract protected
# set_schema( )

Setup this database table

Setup this database table

abstract protected
# upgrade( )

Upgrade this database table

Upgrade this database table

abstract protected mixed
# table_name( )

Provides Table Name.

Provides Table Name.

Returns

mixed
abstract protected mixed
# table_version( )

Provides Table Version Number.

Provides Table Version Number.

Returns

mixed
public
# switch_blog( integer $site_id = 0 )

Update table version & references.

Update table version & references.

Hooked to the "switch_blog" action.

Parameters

$site_id
The site being switched to
public
# maybe_upgrade( )

Maybe upgrade the database table. Handles creation & schema changes.

Maybe upgrade the database table. Handles creation & schema changes.

Hooked to the "admin_init" action.

protected
# after_table_created( )

Works As A Built In Hook To Provide a Option to run after table is created.

Works As A Built In Hook To Provide a Option to run after table is created.

Properties summary
protected string $name

Table name, without the global table prefix

Table name, without the global table prefix

# ''
protected integer $version

Database version

Database version

# 0
protected boolean $global

Is this table for a site, or global

Is this table for a site, or global

# false
protected string $db_version_key

Database version key (saved in _options or _sitemeta)

Database version key (saved in _options or _sitemeta)

# ''
protected integer $db_version

Current database version

Current database version

# 0
protected string $schema

Table schema

Table schema

# ''
protected string $prefix
# null
protected string $charset_collation

Database character-set & collation for table

Database character-set & collation for table

# ''
protected wpdb $db

WPDB Database object (usually $GLOBALS['wpdb'])

WPDB Database object (usually $GLOBALS['wpdb'])

# false
protected static array $_instances

Stores Multiple Class Instance.

Stores Multiple Class Instance.

# array()
API documentation generated by ApiGen