trait SqlTableSelectionTrait (View source)

Note: when using this trait, also implement ConfigAwareInterface/ConfigAwareTrait.

Methods

array
getExpandedTableSelection(array $options, array $all_tables)

Given a list of all tables, expand the convert the wildcards in the option-provided lists into a list of actual table names.

array
expandAndFilterTables(array $tables, array $db_tables)

Given the table names in the input array that may contain wildcards (*), expand the table names so that the array returned only contains table names that exist in the database.

array
expandWildcardTables(array $tables, array $db_tables)

Expand wildcard tables.

array
filterTables(array $tables, array $db_tables)

Filters tables.

array
getTableSelection(array $options)

Construct an array that places table names in appropriate buckets based on whether the table is to be skipped, included for structure only, or have structure and data dumped.

array
getRawTableList(string $option_name, array $options)

Consult the specified options and return the list of tables specified.

Details

array getExpandedTableSelection(array $options, array $all_tables)

Given a list of all tables, expand the convert the wildcards in the option-provided lists into a list of actual table names.

Parameters

array $options

An options array as passed to an Annotated Command.

array $all_tables

A list of all eligible tables.

Return Value

array

array of tables with each table name in the appropriate element of the array.

array expandAndFilterTables(array $tables, array $db_tables)

Given the table names in the input array that may contain wildcards (*), expand the table names so that the array returned only contains table names that exist in the database.

Parameters

array $tables

An array of table names where the table names may contain the * wildcard character.

array $db_tables

The list of tables present in a database.

Return Value

array

array of tables with non-existant tables removed.

array expandWildcardTables(array $tables, array $db_tables)

Expand wildcard tables.

Parameters

array $tables

An array of table names, some of which may contain wildcards (*).

array $db_tables

An array with all the existing table names in the current database.

Return Value

array

array filterTables(array $tables, array $db_tables)

Filters tables.

Parameters

array $tables

An array of table names to filter.

array $db_tables

An array with all the existing table names in the current database.

Return Value

array

array with only valid table names (i.e. all of which actually exist in the database).

array getTableSelection(array $options)

Construct an array that places table names in appropriate buckets based on whether the table is to be skipped, included for structure only, or have structure and data dumped.

The keys of the array are:

  • skip: tables to be skipped completed in the dump
  • structure: tables to only have their structure i.e. DDL dumped
  • tables: tables to have structure and data dumped

Parameters

array $options

Return Value

array

array of table names with each table name in the appropriate element of the array.

array getRawTableList(string $option_name, array $options)

Consult the specified options and return the list of tables specified.

Parameters

string $option_name
array $options

An options array as passed to an Annotated Command.

Return Value

array

an array of tables based on the first option found, or an empty array if there were no matches.