PHP Class N98\Util\Console\Helper\DatabaseHelper

Inheritance: extends Symfony\Component\Console\Helper\Helper
Show file Open project: netz98/n98-magerun Class Usage Examples

Protected Properties

Property Type Description
$_connection PDO
$_tables array
$dbSettings array | N98\Magento\DbSettings
$isSocketConnect boolean

Public Methods

Method Description
createDatabase ( Symfony\Component\Console\Output\OutputInterface $output )
detectDbSettings ( Symfony\Component\Console\Output\OutputInterface $output )
dropDatabase ( Symfony\Component\Console\Output\OutputInterface $output )
dropTables ( Symfony\Component\Console\Output\OutputInterface $output )
dsn ( ) : string Creates a PDO DSN for the adapter from $this->_config settings.
getConnection ( Symfony\Component\Console\Output\OutputInterface $output = null ) : PDO Connects to the database without initializing magento
getDbSettings ( Symfony\Component\Console\Output\OutputInterface $output = null ) : array | DbSettings
getGlobalStatus ( string | null $variable = null ) : array
getGlobalVariables ( string | null $variable = null ) : array
getIsSocketConnect ( ) : boolean
getMysqlClientToolConnectionString ( ) : string
getMysqlVariable ( string $name, string $type = null ) : string obtain mysql variable value from the database connection.
getMysqlVariableValue ( string $variable ) : boolean | array Get mysql variable value
getName ( ) : string Returns the canonical name of this helper.
getTableDefinitions ( array $commandConfig ) : array
getTables ( boolean $withoutPrefix = null ) : array Get list of database tables
getTablesStatus ( boolean $withoutPrefix = false ) : array Get list of db tables status
mysqlUserHasPrivilege ( string $privilege ) : boolean Check whether current mysql user has $privilege privilege
resolveTables ( array $list, array $definitions = [], array $resolved = [] ) : array

Private Methods

Method Description
fallbackOutput ( Symfony\Component\Console\Output\OutputInterface $output = null ) : Symfony\Component\Console\Output\OutputInterface small helper method to obtain an object of type OutputInterface
getApplication ( ) : Application | Application
quoteLike ( string $string, string $escape = '=' ) : string quote a string so that it is safe to use in a LIKE
runShowCommand ( string $command, string | null $variable = null ) : array
throwRuntimeException ( PDOStatement $statement, string $message = "" ) throw a runtime exception and provide error info for the statement if available

Method Details

createDatabase() public method

public createDatabase ( Symfony\Component\Console\Output\OutputInterface $output )
$output Symfony\Component\Console\Output\OutputInterface

detectDbSettings() public method

public detectDbSettings ( Symfony\Component\Console\Output\OutputInterface $output )
$output Symfony\Component\Console\Output\OutputInterface

dropDatabase() public method

public dropDatabase ( Symfony\Component\Console\Output\OutputInterface $output )
$output Symfony\Component\Console\Output\OutputInterface

dropTables() public method

public dropTables ( Symfony\Component\Console\Output\OutputInterface $output )
$output Symfony\Component\Console\Output\OutputInterface

dsn() public method

Creates a PDO DSN for the adapter from $this->_config settings.
See also: Zend_Db_Adapter_Pdo_Abstract
public dsn ( ) : string
return string

getConnection() public method

Connects to the database without initializing magento
public getConnection ( Symfony\Component\Console\Output\OutputInterface $output = null ) : PDO
$output Symfony\Component\Console\Output\OutputInterface = null
return PDO

getDbSettings() public method

public getDbSettings ( Symfony\Component\Console\Output\OutputInterface $output = null ) : array | DbSettings
$output Symfony\Component\Console\Output\OutputInterface [optional]
return array | N98\Magento\DbSettings

getGlobalStatus() public method

public getGlobalStatus ( string | null $variable = null ) : array
$variable string | null [optional]
return array

getGlobalVariables() public method

public getGlobalVariables ( string | null $variable = null ) : array
$variable string | null [optional]
return array

getIsSocketConnect() public method

public getIsSocketConnect ( ) : boolean
return boolean

getMysqlClientToolConnectionString() public method

getMysqlVariable() public method

in difference to @see getMysqlVariableValue(), this method allows to specify the type of the variable as well as to use any variable identifier even such that need quoting.
public getMysqlVariable ( string $name, string $type = null ) : string
$name string mysql variable name
$type string [optional] variable type, can be a system variable ("@@", default) or a session variable ("@").
return string variable value, null if variable was not defined

getMysqlVariableValue() public method

Get mysql variable value
public getMysqlVariableValue ( string $variable ) : boolean | array
$variable string
return boolean | array returns array on success, false on failure

getName() public method

Returns the canonical name of this helper.
public getName ( ) : string
return string The canonical name

getTableDefinitions() public method

public getTableDefinitions ( array $commandConfig ) : array
$commandConfig array
return array

getTables() public method

Get list of database tables
public getTables ( boolean $withoutPrefix = null ) : array
$withoutPrefix boolean [optional] remove prefix from the returned table names. prefix is obtained from magento database configuration. defaults to false.
return array

getTablesStatus() public method

Get list of db tables status
public getTablesStatus ( boolean $withoutPrefix = false ) : array
$withoutPrefix boolean
return array

mysqlUserHasPrivilege() public method

Check whether current mysql user has $privilege privilege
public mysqlUserHasPrivilege ( string $privilege ) : boolean
$privilege string
return boolean

resolveTables() public method

public resolveTables ( array $list, array $definitions = [], array $resolved = [] ) : array
$list array
$definitions array
$resolved array Which definitions where already resolved -> prevent endless loops
return array

Property Details

$_connection protected property

protected PDO $_connection
return PDO

$_tables protected property

protected array $_tables
return array

$dbSettings protected property

protected array|DbSettings,N98\Magento $dbSettings
return array | N98\Magento\DbSettings

$isSocketConnect protected property

Deprecation: since 1.97.9, use $dbSettings->isSocketConnect()
protected bool $isSocketConnect
return boolean