public function listCommand($services = [], $table_pattern = '')
    {
        foreach ($services ?: $this->_getDbServices() as $service) {
            /** @var \ManaPHP\DbInterface $db */
            $db = $this->_di->getShared($service);

            $this->console->writeLn(['service: `:service`', 'service' => $service], Console::FC_CYAN);
            foreach ($this->_getTables($service, $table_pattern) as $row => $table) {
                $columns = (array)$db->getMetadata($table)[Db::METADATA_ATTRIBUTES];
                $primaryKey = $db->getMetadata($table)[Db::METADATA_PRIMARY_KEY];
                foreach ($columns as $i => $column) {
                    if (in_array($column, $primaryKey, true)) {
                        $columns[$i] = $this->console->colorize($column, Console::FC_RED);
                    }
                }

                $this->console->writeLn([' :row :table(:columns)',
                    'row' => sprintf('%2d ', $row + 1),
                    'table' => $this->console->colorize($table, Console::FC_GREEN),
                    'columns' => implode(', ', $columns)]);
            }
        }
    }
public function listCommand($services = [], $table_pattern = '')
    {
        foreach ($services ?: $this->_getDbServices() as $service) {
            /** @var \ManaPHP\DbInterface $db */
            $db = $this->_di->getShared($service);

            $this->console->writeLn(['service: `:service`', 'service' => $service], Console::FC_CYAN);
            foreach ($this->_getTables($service, $table_pattern) as $row => $table) {
                $columns = (array)$db->getMetadata($table)[Db::METADATA_ATTRIBUTES];
                $primaryKey = $db->getMetadata($table)[Db::METADATA_PRIMARY_KEY];
                foreach ($columns as $i => $column) {
                    if (in_array($column, $primaryKey, true)) {
                        $columns[$i] = $this->console->colorize($column, Console::FC_RED);
                    }
                }

                $this->console->writeLn([' :row :table(:columns)',
                    'row' => sprintf('%2d ', $row + 1),
                    'table' => $this->console->colorize($table, Console::FC_GREEN),
                    'columns' => implode(', ', $columns)]);
            }
        }
    }
public function listCommand ( $ services = [ ] , $ table_pattern = '' ) { foreach ( $ services ? : $ this -> _getDbServices ( ) as $ service ) { /** @var \ManaPHP\DbInterface $db */ $ db = $ this -> _di -> getShared ( $ service ) ; $ this -> console -> writeLn ( [ 'service: `:service`' , 'service' => $ service ] , Console :: FC_CYAN ) ; foreach ( $ this -> _getTables ( $ service , $ table_pattern ) as $ row => $ table ) { $ columns = ( array ) $ db -> getMetadata ( $ table ) [ Db :: METADATA_ATTRIBUTES ] ; $ primaryKey = $ db -> getMetadata ( $ table ) [ Db :: METADATA_PRIMARY_KEY ] ; foreach ( $ columns as $ i => $ column ) { if ( in_array ( $ column , $ primaryKey , true ) ) { $ columns [ $ i ] = $ this -> console -> colorize ( $ column , Console :: FC_RED ) ; } } $ this -> console -> writeLn ( [ ' :row :table(:columns)' , 'row' => sprintf ( '%2d ' , $ row + 1 ) , 'table' => $ this -> console -> colorize ( $ table , Console :: FC_GREEN ) , 'columns' => implode ( ', ' , $ columns ) ] ) ; } } }
list databases and tables

@param array  $services services name list
@param string $table_pattern match table against a pattern
list databases and tables