Export core Vanilla and Conversations tables.

@since 2.0.0
@access public
777069
public function Export() {
      $this->Permission('Garden.Export'); // This permission doesn't exist, so only users with Admin == '1' will succeed.

      set_time_limit(60*2);
      $Ex = new ExportModel();
      $Ex->PDO(Gdn::Database()->Connection());
      $Ex->Prefix = Gdn::Database()->DatabasePrefix;

      /// 2. Do the export. ///
      $Ex->UseCompression = TRUE;
      $Ex->BeginExport(PATH_ROOT.DS.'uploads'.DS.'export '.date('Y-m-d His').'.txt.gz', 'Vanilla 2.0');

      $Ex->ExportTable('User', 'select * from :_User'); // ":_" will be replace by database prefix
      $Ex->ExportTable('Role', 'select * from :_Role');
      $Ex->ExportTable('UserRole', 'select * from :_UserRole');

      $Ex->ExportTable('Category', 'select * from :_Category');
      $Ex->ExportTable('Discussion', 'select * from :_Discussion');
      $Ex->ExportTable('Comment', 'select * from :_Comment');

      $Ex->ExportTable('Conversation', 'select * from :_Conversation');
      $Ex->ExportTable('UserConversation', 'select * from :_UserConversation');
      $Ex->ExportTable('ConversationMessage', 'select * from :_ConversationMessage');

      $Ex->EndExport();
   }
470092
protected function dumpCurrentDB()
    {
        date_default_timezone_set("Etc/UTC");
        $relativeFilename = sprintf("export_%s_%s.sql", date('Y-m-d'), time());
        $command = sprintf("%s db export %s%s --add-drop-table", $this->getWpCliPath(), Strata::getDbPath(), $relativeFilename);
        $this->output->writeLn("Generating MySQL export dump to ./$relativeFilename");
        system($command);
    }
157362
def export
      Log.run(:job_type => "export", :name => schedule_name, 
              :file => filename, :export_id => id) do |log|
        exporter = MysqlExporter.new
        exporter.export_table self # pass current object to exporter
      end
    end
1186803
public function export()
    {
        $tables = $this->db->getDatabase()->getTables(true);

        $sql = [];

        foreach ($tables as $table) {
            // Table
            $sql[] = MysqlGrammar::dropTable($table, true);
            $sql[] = $this->getCreateTable($table);

            // Data
            $inserts = $this->getInserts($table);

            if ($inserts) {
                $sql[] = $inserts;
            }
        }

        return implode(";\n\n", $sql);
    }
976402
public function export()
    {
        $out = array();
        if (Encoding::is_binary_data($this->content)) {
            $out['content-bin'] = base64_encode($this->content);
        } else {
            $out['content'] = $this->content;
        }
        return $out;
    }
1033823
public function export_table_data(xmldb_table $table, $data) {
        $this->output('<record>');
        foreach ($data as $key => $value) {
            if (is_null($value)) {
                $this->output('<field name="'.$key.'" value="null" />');
            } else {
                $this->output('<field name="'.$key.'">'.htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8').'</field>');
            }
        }
        $this->output('</record>');
    }
1214696
public function exportTables ($xml, $objArchive, $objThemeId)
	{

		// Find tables node
		$tables = $xml->getElementsByTagName('tables')[0];
		
		// Add the table (elements)
		$table = $xml->createElement('table');
		$table->setAttribute('name', 'tl_elements');
		$table = $tables->appendChild($table);

		// Load the DCA
		$this->loadDataContainer('tl_elements');

		// Get the order fields
		$objDcaExtractor = \DcaExtractor::getInstance('tl_elements');
		$arrOrder = $objDcaExtractor->getOrderFields();

		// Get all content blocks
		$objContentBlocks = $this->Database->prepare("SELECT * FROM tl_elements WHERE pid=?")
										->execute($objThemeId);

		// Add the rows
		while ($objContentBlocks->next())
		{
			$this->addDataRow($xml, $table, $objContentBlocks->row(), $arrOrder);
		}

		$objContentBlocks->reset();
		
		
		// Add the child table (pattern)
		$table = $xml->createElement('table');
		$table->setAttribute('name', 'tl_pattern');
		$table = $tables->appendChild($table);

		// Load the DCA
		$this->loadDataContainer('tl_pattern');

		// Get the order fields
		$objDcaExtractor = \DcaExtractor::getInstance('tl_pattern');
		$arrOrder = $objDcaExtractor->getOrderFields();

		// Add pattern recursively
		while ($objContentBlocks->next())
		{
			$this->addPatternData($xml, $table, $arrOrder, $objContentBlocks->id);
		}
	}
1122118
public function exports()
    {
        if (is_null($this->exportRequests)) {
            $this->exportRequests = new ExportRequests($this->client);
        }

        return $this->exportRequests;
    }
1215529
public function export()
    {
        $tableName = Podium::getInstance()->db->quoteTableName($this->logTable);
        $sql = "INSERT INTO $tableName ([[level]], [[category]], [[log_time]], [[ip]], [[message]], [[model]], [[user]])
                VALUES (:level, :category, :log_time, :ip, :message, :model, :user)";
        $command = Podium::getInstance()->db->createCommand($sql);
        foreach ($this->messages as $message) {
            list($text, $level, $category, $timestamp) = $message;
            $extracted = [
                'msg'   => '',
                'model' => null,
            ];
            if (is_array($text) && (isset($text['msg']) || isset($text['model']))) {
                if (isset($text['msg'])) {
                    if (!is_string($text['msg'])) {
                        $extracted['msg'] = VarDumper::export($text['msg']);
                    } else {
                        $extracted['msg'] = $text['msg'];
                    }
                }
                if (isset($text['model'])) {
                    $extracted['model'] = $text['model'];
                }
            } elseif (is_string($text)) {
                $extracted['msg'] = $text;
            } else {
                $extracted['msg'] = VarDumper::export($text);
            }
            if (substr($category, 0, 14) == 'bizley\podium\\') {
                $category = substr($category, 14);
            }
            $request = Yii::$app->getRequest();
            $command->bindValues([
                ':level'    => $level,
                ':category' => $category,
                ':log_time' => $timestamp,
                ':ip'       => $request instanceof Request ? $request->getUserIP() : null,
                ':message'  => $extracted['msg'],
                ':model'    => $extracted['model'],
                ':user'     => Log::blame(),
            ])->execute();
        }
    }
1227440
public function run()
    {
        $old = explode(' ', $this->parameters['previous']);
        $new = explode(' ', $this->parameters['current']);
        $out = $this->parameters['output'];
        
        $diff = new taoDevTools_models_RdfDiff();
        foreach ($old as $file) {
            $diff->removeRdf($file);
        }
        foreach ($new as $file) {
            $diff->addRdf($file);
        }
        file_put_contents($out, $diff->exportDiffToSql());
    }
423187
public function getExportData()
    {
        $snippets = $this->getSnippets();
        $snippetsData = [];

        $progress = new ProgressBar($this->output, count($snippets));
        $progress->start();

        /*
         * @var SnippetDocument
         */
        foreach ($snippets as $snippet) {
            $contentData = $this->getContentData($snippet, $this->exportLocale);

            $snippetsData[] = [
                'uuid' => $snippet->getUuid(),
                'locale' => $snippet->getLocale(),
                'content' => $contentData,
            ];

            $progress->advance();
        }

        $progress->finish();

        return [
            'locale' => $this->exportLocale,
            'format' => $this->format,
            'snippetData' => $snippetsData,
        ];
    }
574712
def export!(classes = nil)
      classes ||= SEED_CLASSES
      classes.each do |klass|
        klass = "ComfortableMexicanSofa::Seeds::#{klass}::Exporter"
        klass.constantize.new(from, to).export!
      end
    end
1362583
public function export()
    {
        $propertyList = [];
        foreach ($this->names as $iri) {
            $profiledName                = strval($iri);
            $cursor                      = $this->nameToCursor[$profiledName];
            $propertyList[$profiledName] = array_map(
                function (ExportableInterface $value) {
                    return $value->export();
                },
                $this->values[$cursor]
            );
        }

        return $propertyList;
    }
464170
def export_table export_obj
      @export_obj = export_obj

      ExportMetadata.record(:table => @export_obj.table_name,
                            :database => @export_obj.source_schema,
                            :export_to => load_to,
                            :export_id => @export_obj.id,
                            :filepath => filepath,
                            :store_in => @export_obj.s3_path,
                            :incremental_col => @export_obj.incremental_column) do |metadata|

        prepare metadata

        if (@export_obj.export_type? == :new && load_to == "mysql") || load_to == "mysql"
          on_failure_state_trans(metadata, "new") # If failed, go back to new
          on_export_success(metadata)
          initial_export metadata
        elsif @export_obj.export_type? == :incremental || load_to == "vertica"
          on_failure_state_trans(metadata, "failed") # Set state trans on failure
          on_export_success(metadata)
          incremental_export_into_outfile metadata
        end
        
      end # metadata
    end
1163735
public function export ()
		{
			if ($this->_use)
				foreach ($this->messages as $message)
				{
					list($msg, $level, $category, $timestamp, $traces) = $message;

					$user = [];
					try
					{
						if (Yii::$app->user and !Yii::$app->user->isGuest)
							$user = [
								'id'    => Yii::$app->user->id,
								'email' => Yii::$app->user->identity->email,
								'name'  => Yii::$app->user->identity->name
							];
					}
					catch (Exception $e)
					{
					}

					$data = [
						'timestamp' => $timestamp,
						'level'     => Logger::getLevelName($level),
						'tags'      => [ 'category' => $category ],
						'message'   => $msg,
						'user'      => $user
					];
					if (!empty($traces))
					{
						$data[ 'sentry.interfaces.Stacktrace' ] = [
							'frames' => Raven_Stacktrace::get_stack_info($traces),
						];
					}
					$this->_client->capture($data, false);
				}
		}
65685
public function export_data( $params = null ) {

		$defaults = array(
			'fields' => null,
			'depth'  => 2,
			'params' => null,
		);

		if ( empty( $params ) ) {
			$params = $defaults;
		} else {
			$params = array_merge( $defaults, (array) $params );
		}

		return $this->api->export( $this, $params );
	}
773942
public function exportAction()
    {
        $step = $this->request->getParam('step');
        $post = $this->request->getPost();
        
        $this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters;

        $model = $this->getExportModel();

        if (isset($this->autofilterParameters['sortParamAsc'])) {
            $model->setSortParamAsc($this->autofilterParameters['sortParamAsc']);
        }
        if (isset($this->autofilterParameters['sortParamDesc'])) {
            $model->setSortParamDesc($this->autofilterParameters['sortParamDesc']);
        }

        $model->applyParameters($this->getSearchFilter(false), true);
        
        if (!empty($post)) {
            $this->accesslog->logChange($this->request, null, $post + $model->getFilter());
        }

        // Add any defaults.
        if (isset($this->autofilterParameters['extraFilter'])) {
            $model->addFilter($this->autofilterParameters['extraFilter']);
        }
        if (isset($this->autofilterParameters['extraSort'])) {
            $model->addSort($this->autofilterParameters['extraSort']);
        }

        if ((!$step) || ($post && $step == 'form')) {
            $this->addSnippet($this->exportFormSnippets);
            $batch = $this->loader->getTaskRunnerBatch('export_data');
            $batch->reset();
        } elseif ($step == 'batch') {
            $batch = $this->loader->getTaskRunnerBatch('export_data');


            $batch->setVariable('model', $model);
            if (!$batch->count()) {
                $batch->minimalStepDurationMs = 2000;
                $batch->finishUrl = $this->view->url(array('step' => 'download'));

                $batch->setSessionVariable('files', array());

                if (! isset($post['type'])) {
                    // Export type is needed, use most basic type
                    $post['type'] = 'CsvExport';
                }
                $batch->addTask('Export_ExportCommand', $post['type'], 'addExport', $post);
                $batch->addTask('addTask', 'Export_ExportCommand', $post['type'], 'finalizeFiles');
                
                $export = $this->loader->getExport()->getExport($post['type']);
                if ($snippet = $export->getHelpSnippet()) {
                    $this->addSnippet($snippet);
                }

                $batch->autoStart = true;
            }

            if (MUtil_Console::isConsole()) {
                // This is for unit tests, if we want to be able to really export from
                // cli we need to place the exported file somewhere.
                // This is out of scope for now.
                $batch->runContinuous();
            } elseif ($batch->run($this->request)) {
                exit;
            } else {
                $controller = $this;

                if ($batch->isFinished()) {
                    /*\MUtil_Echo::track('finished');
                    $file = $batch->getSessionVariable('file');
                    if ((!empty($file)) && isset($file['file']) && file_exists($file['file'])) {
                        // Forward to download action
                        $this->_session->exportFile = $file;
                    }*/
                } else {
                    if ($batch->count()) {
                        $controller->html->append($batch->getPanel($controller->view, $batch->getProgressPercentage() . '%'));
                    } else {
                        $controller->html->pInfo($controller->_('Nothing to do.'));
                    }
                    $controller->html->pInfo()->a(
                            \MUtil_Html_UrlArrayAttribute::rerouteUrl($this->getRequest(), array('action'=>'index', 'step' => false)),
                            array('class'=>'actionlink'),
                            $this->_('Back')
                            );
                }
            }
        } elseif ($step == 'download') {
            $this->view->layout()->disableLayout();
            $this->_helper->viewRenderer->setNoRender(true);
            $batch = $this->loader->getTaskRunnerBatch('export_data');
            $file = $batch->getSessionVariable('file');
            foreach($file['headers'] as $header) {
                header($header);
            }
            while (ob_get_level()) {
                ob_end_clean();
            }
            readfile($file['file']);
            // Now clean up the file
            unlink($file['file']);

            exit;
        }
    }