Recent

Dbclass

Db

Database class

Namespace: WebberZone\Better_Search
Since: 4.2.0
Source: includes/class-db.php line 19

Methods

create_fulltext_indexes() static

Create fulltext indexes on the posts table.

Since: 3.3.0
Line: 133

static public function create_fulltext_indexes(  );

delete_fulltext_indexes() static

Delete the FULLTEXT index.

Since: 4.2.0
Line: 154

static public function delete_fulltext_indexes(  );

is_index_installed() static

Check if a fulltext index already exists on the posts table.

Since: 4.0.0
Line: 177

static public function is_index_installed( $index ): bool;
Type Name Description
string $index Index name.

Returns: bool — True if the index exists, false otherwise.

index_exists() static

Check if an index with this exact name exists on the posts table.

Unlike is_index_installed(), this ignores legacy aliases - use it when acting on the index itself, e.g. building DROP statements.

Since: 4.4.0
Line: 194

static public function index_exists( $index ): bool;
Type Name Description
string $index Index name.

Returns: bool — True if the index exists, false otherwise.

install_fulltext_index() static

Install a fulltext index on the posts table.

Since: 4.0.0
Line: 220

static public function install_fulltext_index( $index, $columns ): void;
Type Name Description
string $index Index name.
string $columns Columns to be indexed.

Returns: void

get_fulltext_indexes() static

Get the list of fulltext indexes to be created on the posts table.

Since: 4.0.0
Line: 235

static public function get_fulltext_indexes(  ): array;

Returns: array — Array of fulltext indexes with their respective columns.

get_old_fulltext_indexes() static

Get the list of old fulltext indexes.

Since: 4.2.0
Line: 259

static public function get_old_fulltext_indexes(  ): array;

Returns: array — Array of fulltext indexes with their respective columns.

get_legacy_index_aliases() static

Get the map of current index names to the legacy index name each one replaces.

The wz_ indexes are shared across WebberZone plugins, so a sibling plugin’s index on the same columns satisfies ours.

Since: 4.4.0
Line: 277

static public function get_legacy_index_aliases(  ): array;

Returns: array — Map of current index name => legacy index name.

maybe_heal_fulltext_indexes() static

Create any missing FULLTEXT indexes once per index schema version.

Existing installs never re-run activation, so a newly registered index would otherwise wait on the user clicking through the missing-index notice.

Since: 4.4.0
Line: 303

static public function maybe_heal_fulltext_indexes(  );

check_fulltext_indexes() static

Check the status of all fulltext indexes.

Since: 4.0.0
Line: 332

static public function check_fulltext_indexes(  ): array;

Returns: array — Array of index statuses with ‘installed’ boolean flag and ‘status’ text.

is_fulltext_index_installed() static

Check if all fulltext indexes are installed.

Since: 4.0.0
Line: 368

static public function is_fulltext_index_installed( $use_cache = ... ): bool;
Type Name Description
bool $use_cache Whether to use the persistent status cache.

Returns: bool — True if all fulltext indexes are installed, false if any are missing.

clear_index_status_cache() static

Clear the FULLTEXT index status cache.

Since: 4.4.3
Line: 492

static public function clear_index_status_cache(  );

is_table_installed() static

Check if the Better Search table is installed.

Since: 4.0.2
Line: 507

static public function is_table_installed( $table_name, $use_cache = ... ): bool;
Type Name Description
string $table_name Table name.
bool $use_cache Whether to use the persistent table-status cache.

Returns: bool — True if the table exists, false otherwise.

clear_table_status_cache() static

Clear the local table-status cache.

Since: 4.4.3
Line: 585

static public function clear_table_status_cache(  );

get_network_table_status() static

Get the network-wide status of Better Search tables.

A single SHOW TABLES query discovers both Better Search table families. The result is persisted because the per-site network statistics code otherwise performs one metadata query for every site and table suffix on each request.

Since: 4.4.3
Line: 602

static public function get_network_table_status( $force = ... ): array;
Type Name Description
bool $force Whether to bypass the persistent and in-request caches.

Returns: array — Network table-status cache.

refresh_network_table_status() static

Refresh the network-wide table-status cache from the database.

This is intentionally a live check. It is used by the scheduled health check and diagnostic tools, while normal dashboard requests use the cached status.

Since: 4.4.3
Line: 671

static public function refresh_network_table_status(  ): array;

Returns: array — Network table-status cache.

maybe_refresh_network_table_status() static

Run the live network table check when the admin health interval has elapsed.

Since: 4.4.3
Line: 688

static public function maybe_refresh_network_table_status(  ): array;

Returns: array — Network table-status cache.

schedule_network_table_status_check() static

Schedule the network table-status health check if it is not already scheduled.

Since: 4.4.3
Line: 729

static public function schedule_network_table_status_check(  );

unschedule_network_table_status_check() static

Unschedule the network table-status health check.

Since: 4.4.3
Line: 740

static public function unschedule_network_table_status_check(  );

clear_network_table_status_cache() static

Clear the network-wide table-status cache.

Since: 4.4.3
Line: 749

static public function clear_network_table_status_cache(  );

maybe_create_table() static

Create table if not exists.

Since: 4.2.0
Line: 766

static public function maybe_create_table( $table_name, $sql );
Type Name Description
string $table_name Table name.
string $sql SQL to create the table.

create_tables() static

Create tables.

Since: 4.2.0
Line: 783

static public function create_tables(  );

create_full_table_sql() static

Create full table sql.

Since: 4.2.0
Line: 798

static public function create_full_table_sql(  ): string;

Returns: string — SQL to create the full table.

create_daily_table_sql() static

Create full daily table sql.

Since: 4.2.0
Line: 821

static public function create_daily_table_sql(  ): string;

Returns: string — SQL to create the daily table.

recreate_table() static

Recreate a table.

This method recreates a table by creating a backup, dropping the original table, and then creating a new table with the original name and inserting the data from the backup.

Since: 4.2.0
Line: 855

static public function recreate_table( $table_name, $create_table_sql, $backup = ..., $fields = ..., $group_by_fields = ... ): bool|\WP_Error;
Type Name Description
string $table_name The name of the table to recreate.
string $create_table_sql The SQL statement to create the new table.
bool $backup Whether to backup the table or not.
array $fields The fields to include in the temporary table and on duplicate key code.
array $group_by_fields The fields to group by in the temporary table.

Returns: bool|\WP_Error — True if recreated, error message if failed.

recreate_overall_table() static

Recreate overall table.

Since: 4.2.0
Line: 909

static public function recreate_overall_table( $backup = ... ): bool|\WP_Error;
Type Name Description
bool $backup Whether to backup the table or not.

Returns: bool|\WP_Error — True if recreated, error message if failed.

recreate_daily_table() static

Recreate daily table.

Since: 4.2.0
Line: 927

static public function recreate_daily_table( $backup = ... ): bool|\WP_Error;
Type Name Description
bool $backup Whether to backup the table or not.

Returns: bool|\WP_Error — True if recreated, error message if failed.