SqlMysql
class SqlMysql extends SqlBase (View source)
Traits
Note: when using this trait, also implement ConfigAwareInterface/ConfigAwareTrait.
Properties
protected ConfigInterface | $config | from ConfigAwareTrait | |
string | $queryExtra | ||
string | $queryFile | from SqlBase | |
protected Process | $process | from SqlBase | |
protected | $uri | from ExecTrait | |
protected string | $version |
Methods
Given a list of all tables, expand the convert the wildcards in the option-provided lists into a list of actual table names.
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.
Expand wildcard tables.
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.
Consult the specified options and return the list of tables specified.
Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().
No description
No description
Typically, SqlBase instances are constructed via SqlBase::create($options).
Get a driver specific instance of this class.
The unix command used to connect to the database.
Handle 'pipefail' option for the specified command.
No description
Execute a SQL query. Respect simulate mode.
Execute a SQL query. Always execute regardless of simulate mode.
Show the query in debug mode and simulate mode
No description
Build a SQL string for dropping and creating a database.
No description
Build a string containing connection credentials.
Extract the name of all existing tables in the given database.
Extract the name of all existing tables in the given database.
Convert from an old-style database URL to an array of database settings.
Starts a background browser/tab for the current site or a specified URL.
A factory method which creates a mysql or mariadb instance as needed.
No description
The server version.
No description
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.
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.
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
array
getRawTableList(string $option_name, array $options)
Consult the specified options and return the list of tables specified.
$this
setConfig(ConfigInterface $config)
Set the config management object.
ConfigInterface
getConfig()
Get the config management object.
static protected string
configPrefix()
Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().
static protected
configClassIdentifier($classname)
No description
static protected
configPostfix()
No description
static
configure(string $key, mixed $value, ConfigInterface|null $config = null)
No description
protected mixed|null
getConfigValue(string $key, mixed|null $default = null)
No description
__construct(array $dbSpec, array $options)
Typically, SqlBase instances are constructed via SqlBase::create($options).
array
getEnv()
Get environment variables to pass to Process.
Process
getProcess()
Get the last used Process.
void
setProcess(Process $process)
No description
static SqlBase|null
create(array $options = [])
Get a driver specific instance of this class.
static SqlBase|null
getInstance($db_spec, $options)
No description
array
getDbSpec()
No description
void
setDbSpec(array $dbSpec)
Set the current db spec.
string
command()
The unix command used to connect to the database.
string
connect(bool $hide_password = true)
A string for connecting to a database.
string|bool|null
dump()
No description
protected string
addPipeFail(string $cmd, string $pipefail)
Handle 'pipefail' option for the specified command.
string
dumpCmd($table_selection)
No description
string|null
dumpFile($file)
No description
bool|null
query(string $query, $input_file = null, $result_file = '')
Execute a SQL query. Respect simulate mode.
If you don't want to query results to print during --debug then provide a $result_file whose value can be drush_bit_bucket().
bool
alwaysQuery(string $query, $input_file = null, string|null $result_file = '')
Execute a SQL query. Always execute regardless of simulate mode.
If you don't want results to print during --debug then provide a $result_file whose value can be drush_bit_bucket().
protected void
logQueryInDebugMode($query, $input_file_original)
Show the query in debug mode and simulate mode
string|null
silent()
No description
string|null
queryPrefix($query)
No description
queryFormat($query)
No description
bool|null
drop(array $tables)
Drop specified database.
string
createdbSql(string $dbname, bool $quoted = false)
Build a SQL string for dropping and creating a database.
bool|null
createdb(bool $quoted = false)
Create a new database.
bool
dropOrCreate()
Drop all tables (if DB exists) or CREATE target database.
return TRUE or FALSE depending on success.
bool
dbExists()
No description
string
creds(bool $hide_password = true)
Build a string containing connection credentials.
string
scheme()
The active database driver.
array
listTables()
Extract the name of all existing tables in the given database.
array
listTablesQuoted()
Extract the name of all existing tables in the given database.
string
paramsToOptions($parameters)
No description
void
su()
Adjust DB connection with superuser credentials if provided.
array
getOptions()
No description
getOption($name, $default = null)
No description
static array
dbSpecFromDbUrl($db_url)
Convert from an old-style database URL to an array of database settings.
array
alwaysQueryCommand($input_file)
Start building the command to run a query.
bool
startBrowser(string|null $uri = null, int $sleep = 0, int|null $port = null, string|bool $browser = false)
Starts a background browser/tab for the current site or a specified URL.
Uses a non-blocking Process call, so Drush execution will continue.
static bool
programExists($program)
No description
static string
getEditor(string|null $editor = null)
No description
static
make(array $dbSpec, array $options)
A factory method which creates a mysql or mariadb instance as needed.
string
dumpProgram()
No description
string
getVersion()
The server version.
void
setVersion(string $version)
No description