/** * export * * @param bool $ignoreTrack * @param bool $prefixOnly * * @return mixed|string */ public function export($ignoreTrack = false, $prefixOnly = false) { $tableObject = new Table(); $trackObject = new Track(); $tables = $prefixOnly ? $tableObject->listSite() : $tableObject->listAll(); $track = $trackObject->getTrackList(); $sql = array(); $this->tableCount = 0; $this->rowCount = 0; foreach ($tables as $table) { $trackStatus = $track->get('table.' . $table, 'none'); if ($trackStatus == 'none' && !$ignoreTrack) { continue; } $sql[] = $this->queryHelper->dropTable($table); $sql[] = $this->getCreateTable($table); $this->tableCount++; if ($trackStatus == 'all' || $ignoreTrack) { $insert = $this->getInserts($table); if ($insert) { $sql[] = $insert; } } } $this->state->set('dump.count.tables', $this->tableCount); $this->state->set('dump.count.rows', $this->rowCount); return implode(";\n\n", $sql); }
/** * export * * @param bool $ignoreTrack * @param bool $prefixOnly * @param bool $text * * @return mixed|string */ public function export($ignoreTrack = false, $prefixOnly = false, $text = true) { $tableObject = new Table(); $trackObject = new Track(); $tables = $prefixOnly ? $tableObject->listSite() : $tableObject->listAll(); $track = $trackObject->getTrackList(); $result = array(); $this->tableCount = 0; $this->rowCount = 0; foreach ($tables as $table) { $trackStatus = $track->get('table.' . $table, 'none'); if ($trackStatus == 'none' && !$ignoreTrack) { continue; } $result[$table] = $this->getCreateTable($table); $this->tableCount++; if ($trackStatus == 'all' || $ignoreTrack) { $insert = $this->getInserts($table); if ($insert) { $result[$table] = array_merge($result[$table], $insert); } } } $this->state->set('dump.count.tables', $this->tableCount); $this->state->set('dump.count.rows', $this->rowCount); $dumper = new Dumper(); $result = json_decode(json_encode($result), true); return $text ? $dumper->dump($result, 3, 0, false, true) : $result; }
/** * Execute this command. * * @return int|void */ protected function doExecute() { $track = new Track(); $args = $this->io->getArguments(); $all = $this->getOption('a'); $site = $this->getOption('s'); if (empty($args[0]) && !$all && !$site) { $this->out()->out('Missing argument 1 <table_name> or -a|--all, -s|--site.'); return; } if ($all && $site) { $this->out()->out('Do you want to track tables of all or just this site?'); return; } $tableObject = new Table(); if ($all) { $tables = $tableObject->listAll(); } elseif ($site) { $tables = $tableObject->listSite(); } else { $tables = array($args[0]); } $track->setTrack($tables, $this->status); if (count($tables) > 1) { $name = count($tables) . ' tables'; } else { $name = $tables[0]; } $this->out()->out(sprintf('Set %s tracking %s.', $name, $this->status)); }
/** * Execute this command. * * @return int|void */ protected function doExecute() { $tableModel = new Table(); if ($this->getOption('a')) { $profiles = ProfileHelper::getAllProfiles(); } else { $profiles = $this->io->getArguments() ?: array(ProfileHelper::getProfile()); } $config = Factory::getConfig(); foreach ($profiles as $profile) { $config->set('profile', $profile); $tableModel->sync(); $path = $tableModel->getState()->get('track.save.path'); $this->out()->out('Sync all tracking status to: ' . $path); } return; }
/** * Execute this command. * * @return int|void */ protected function doExecute() { $tableModel = new Table(); $statuses = $tableModel->status(); $tables = ArrayHelper::getColumn($statuses, 'table'); $maxLength = max(array_map('strlen', $tables)); // Show message $this->out()->out('Track Status:')->out(); $titleSpaces = $maxLength - 5; $this->out(sprintf("TABLE NAME %-{$titleSpaces}s STATUS", '')); $this->out('---------------------------------------------------------------'); // List table & status foreach ($statuses as $status) { $spaces = $maxLength - strlen($status['table']) + 4; $this->out(sprintf("- %s %-{$spaces}s %s", $status['table'], '', $status['status'])); } }
/** * Execute this command. * * @return int|void */ protected function doExecute() { $tableObject = new Table(); if ($this->getOption('a')) { $tables = $tableObject->listAll(); } else { $tables = $tableObject->listSite(); } foreach ($tables as $table) { $this->out('- ' . $table); } // Count all tables in this db $count = count($tableObject->listAll()); // Output1 $this->out(); $this->out('List tables: ' . count($tables)); $this->out('All tables in this database: ' . $count); }
/** * getTableList * * @return array|mixed */ protected function getTableList() { if (!empty($this->tables)) { return $this->tables; } $tableModel = new Table(); $tables = $tableModel->listAll(); return $this->tables = $tables; }