Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $client = $this->option('client');
     if (empty($client)) {
         $this->error('No client specified!');
         exit(1);
     }
     $table = $this->option('table');
     if (empty($table)) {
         $this->error('No table specified!');
         exit(1);
     }
     $pk = $this->option('pk');
     if (empty($pk)) {
         $pk = $table . '_id';
     }
     $prefix = $this->option('file-prefix');
     if (empty($prefix)) {
         $prefix = $client . '-' . $table . '-' . date('YmdHis');
     }
     $this->extractor->configure($client, $table, $pk, $prefix);
     // get and add client ID as fixture data
     $client_id = $this->client_service->getClientId($client);
     $this->extractor->addFixtureData('client_id', $client_id);
     if (!$this->option('quiet')) {
         $progress_bar = $this->output->createProgressBar(100);
         $this->extractor->setProgressBar($progress_bar);
         $this->info('Extracting ' . $table . ' from tools client ' . $client . ' to files at ' . $prefix . '.');
     }
     $this->extractor->extractAll();
     if (!$this->option('quiet')) {
         $this->info("\n");
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $client = $this->option('client');
     if (empty($client)) {
         $this->error('No client specified!');
         exit(1);
     }
     $table = $this->option('table');
     if (empty($table)) {
         $this->error('No table specified!');
         exit(1);
     }
     $pk = $this->option('pk');
     if (empty($pk)) {
         $pk = $table . '_id';
     }
     $conn = $this->client_service->getPdoConnection($client);
     $desc_sth = $conn->query('DESC ' . $table);
     $desc = $desc_sth->fetchAll(PDO::FETCH_ASSOC);
     $ddl = $this->sql_service->stagingTableFromToolsTable($table, $pk, $desc);
     $this->info($ddl);
 }