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.

$tables
expandWildcardTables(array $tables, array $db_tables)

Expand wildcard tables.

An
filterTables(array $tables, array $db_tables)

Filters tables.

array
getTableSelection($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(option_name $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 An 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 An array of tables with non-existant tables removed.

$tables 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

$tables array with wildcards resolved to real table names.

An 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

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

array getTableSelection($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

$options

Return Value

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

array getRawTableList(option_name $option_name, array $options)

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

Parameters

option_name $option_name The option name to check: skip-tables, structure-tables or tables. This function will check both *-key and *-list.
array $options An options array as passed to an Annotated Command.

Return Value

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