Creates the search log db table
@return void
343790
public static function install()
    {
        update_option('search-statistics-db-version', 0);
        $charsetCollation = self::$wpdb->get_charset_collate();
        $tableName = self::$dbTable;

        if (!empty(get_site_option('search-statistics-db-version')) && self::$wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
            return;
        }

        $sql = "CREATE TABLE $tableName (
            id bigint(20) NOT NULL AUTO_INCREMENT,
            query varchar(255) DEFAULT NULL,
            results bigint(20) DEFAULT 0 NOT NULL,
            site_id bigint(20) DEFAULT NULL,
            logged_in tinyint(1) DEFAULT 0 NOT NULL,
            date_searched timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
            UNIQUE KEY id (id)
        ) $charsetCollation;";

        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);

        update_option('search-statistics-db-version', 2);
    }
740568
protected function createTable()
    {
        if ($this->db->schema->getTableSchema($this->sessionTable) === null) {
            $cmd = $this->db->createCommand();
            $cmd->createTable($this->sessionTable, [
                'id' => 'CHAR(40) PRIMARY KEY',
                'expire' => 'integer',
                'data' => 'binary',
            ])->execute();
        }
    }
536052
public function actionLogs()
    {
        $searchModel = new LogSearch();
        return $this->render('logs', [
            'dataProvider' => $searchModel->search(Yii::$app->request->get()),
            'searchModel' => $searchModel,
        ]);
    }
1224166
protected function createMigrationHistoryTable()
    {
        $tableName = $this->db->schema->getRawTableName($this->migrationTable);
        $this->stdout("Creating migration history table \"$tableName\"...", Console::FG_YELLOW);
        $this->db->createCommand()->createTable($this->migrationTable, [
            'version'    => 'VARCHAR(180) NOT NULL PRIMARY KEY',
            'apply_time' => 'INTEGER',
        ])->execute();
        $this->db->createCommand()->insert($this->migrationTable, [
            'version' => self::BASE_MIGRATION,
            'apply_time' => time(),
        ])->execute();
        $this->stdout("Done.\n", Console::FG_GREEN);
    }
143308
protected function createTables()
    {
        $this->createTable(static::tableName(), [
            'objectId' => $this->string()->notNull(),
            'elementId' => $this->integer()->notNull(),
            'fieldId' => $this->integer()->notNull(),
            'siteId' => $this->integer()->notNull(),
            'sortOrder' => $this->smallInteger()->unsigned(),
            'dateCreated' => $this->dateTime()->notNull(),
            'dateUpdated' => $this->dateTime()->notNull(),
            'uid' => $this->uid(),
        ]);
    }
568597
protected function createTableIfNeeded()
    {
        if ($this->tableExists) {
            return false;
        }

        if ($this->tableExist($this->tableName)) {
            $this->tableExists = true;
            return false;
        }

        $this->createTable();

        $this->tableExists = true;
        return true;
    }
818841
protected function createTable()
    {
        $template = file_get_contents(dirname(__FILE__) . '/TableSchema.sql');
        $this->pdo->query(sprintf($template, $this->table));
    }
1338322
public function createTables() {
		try {
			$this->client->createTable(
				[
					'TableName'             => 'wpsnapshots-' . $this->repository,
					'AttributeDefinitions'  => [
						[
							'AttributeName' => 'id',
							'AttributeType' => 'S',
						],
					],
					'KeySchema'             => [
						[
							'AttributeName' => 'id',
							'KeyType'       => 'HASH',
						],
					],
					'ProvisionedThroughput' => [
						'ReadCapacityUnits'  => 10,
						'WriteCapacityUnits' => 20,
					],
				]
			);

			$this->client->waitUntil(
				'TableExists', [
					'TableName' => 'wpsnapshots-' . $this->repository,
				]
			);
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return $e->getAwsErrorCode();
		}

		return true;
	}
1231953
private function createMigrationTable()
    {
        $adapter = Database::getConnectionAdapter();
        $table = $adapter->getTablePrefix().config('database.migration');
        $generator = new SQLGenerator(
            $table,
            $adapter->getName(),
            'create'
        );

        $generator->addColumn('migration', 'string', ['unique' => true]);
        $generator->addColumn('batch', 'int');
        $generator->addColumn('created_at', 'datetime', [
            'default' => 'CURRENT_TIMESTAMP',
            'nullable' => true
        ]);

        $sql = sprintf(
            'CREATE TABLE IF NOT EXISTS %s (%s);',
            $table,
            $generator->make()
        );

        return Database::statement($sql);
    }
589087
public function export()
    {
        $tableName = $this->db->quoteTableName($this->logTable);
        $sql = "INSERT INTO $tableName ([[level]], [[category]], [[log_time]], [[prefix]], [[message]])
                VALUES (:level, :category, :log_time, :prefix, :message)";
        $command = $this->db->createCommand($sql);
        foreach ($this->messages as $message) {
            list($text, $level, $category, $timestamp) = $message;
            if (!is_string($text)) {
                // exceptions may not be serializable if in the call stack somewhere is a Closure
                if ($text instanceof \Exception) {
                    $text = (string) $text;
                } else {
                    $text = VarDumper::export($text);
                }
            }
            $command->bindValues([
                ':level' => $level,
                ':category' => $category,
                ':log_time' => $timestamp,
                ':prefix' => $this->getMessagePrefix($message),
                ':message' => $text,
            ])->execute();
        }
    }
356478
public function setup_table() {
        $readers = $this->get_readers();

        $filter = new \stdClass();
        if (!empty($this->course)) {
            $filter->courseid = $this->course->id;
        } else {
            $filter->courseid = 0;
        }

        $filter->userid = $this->userid;
        $filter->modid = $this->modid;
        $filter->groupid = $this->get_selected_group();
        $filter->logreader = $readers[$this->selectedlogreader];
        $filter->edulevel = $this->edulevel;
        $filter->action = $this->action;
        $filter->date = $this->date;
        $filter->orderby = $this->order;
        $filter->origin = $this->origin;
        // If showing site_errors.
        if ('site_errors' === $this->modid) {
            $filter->siteerrors = true;
            $filter->modid = 0;
        }

        $this->tablelog = new report_log_table_log('report_log', $filter);
        $this->tablelog->define_baseurl($this->url);
        $this->tablelog->is_downloadable(true);
        $this->tablelog->show_download_buttons_at(array(TABLE_P_BOTTOM));
    }
983452
private function createTable()
    {
        $stmt = 'CREATE TABLE IF NOT EXISTS "' . $this->name;
        $stmt.= '" ("' . $this->keyColumnName . '" TEXT PRIMARY KEY, "';
        $stmt.= $this->valueColumnName . '" TEXT);';
        $this->db->exec($stmt);
    }
1059999
public function createTable()
    {
        if ($this->tableExists() === true) {
            return true;
        }

        $dbh      = $this->db();
        $driver   = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
        $model    = $this->model();
        $metadata = $model->metadata();

        $table   = $this->table();
        $fields  = $this->getModelFields($model);
        $columns = [];
        foreach ($fields as $field) {
            $columns[] = $field->sql();
        }

        $query  = 'CREATE TABLE  `'.$table.'` ('."\n";
        $query .= implode(',', $columns);

        $key = $model->key();
        if ($key) {
            $query .= ', PRIMARY KEY (`'.$key.'`) '."\n";
        }

        /** @todo Add indexes for all defined list constraints (yea... tough job...) */
        if ($driver === self::MYSQL_DRIVER_NAME) {
            $engine = 'InnoDB';
            $query .= ') ENGINE='.$engine.' DEFAULT CHARSET=utf8 COMMENT="'.addslashes($metadata['name']).'";';
        } else {
            $query .= ');';
        }

        $this->logger->debug($query);
        $dbh->query($query);

        return true;
    }
46606
protected function createDirs() {
		@mkdir( 'tests' );
		@mkdir( $this->logDir );
		@mkdir( $this->dataDir );
		@mkdir( $this->helperDir );
	}
557824
public function CreateIndexTables()
    {
        $aIndexTableNames = TdbShopSearchIndexer::GetAllIndexTableNames();
        $aTmpIndex = array();
        foreach ($aIndexTableNames as $sTableName => $length) {
            $aTmpIndex['_tmp'.$sTableName] = $length;
        }
        $aIndexTableNames = $aTmpIndex;
        foreach ($aIndexTableNames as $sTableName => $iLength) {
            if (TCMSRecord::TableExists($sTableName)) {
                $query = "DROP TABLE `{$sTableName}`";
                MySqlLegacySupport::getInstance()->query($query);
            }
            $sPrimaryKey = '';
            $query = 'CREATE TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($sTableName)."` (
                    `shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
                    `substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
                    `cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
                    `occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
                    `weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
                    `shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
                    {$sPrimaryKey}
                  )";
            MySqlLegacySupport::getInstance()->query($query);
        }

        // drop index fields not needed
        $sBaseName = '_tmp'.self::INDEX_TBL_PREFIX;
        $query = "SHOW TABLES LIKE '".MySqlLegacySupport::getInstance()->real_escape_string($sBaseName)."%'";
        $rTableRes = MySqlLegacySupport::getInstance()->query($query);
        while ($aTableData = MySqlLegacySupport::getInstance()->fetch_row($rTableRes)) {
            if (!array_key_exists($aTableData[0], $aIndexTableNames)) {
                $query = 'DROP TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($aTableData[0]).'`';
                MySqlLegacySupport::getInstance()->query($query);
            }
        }
    }
5787
public function log()
	{
		$mode      = $this->output->getMode();
		$length    = ($this->arguments->getOpt('length')) ? (int)$this->arguments->getOpt('length') : 20;
		$start     = ($this->arguments->getOpt('start')) ? (int)$this->arguments->getOpt('start') : null;
		$upcoming  = $this->arguments->getOpt('include-upcoming');
		$installed = ($this->arguments->getOpt('exclude-installed')) ? false : true;
		$search    = ($this->arguments->getOpt('search')) ? $this->arguments->getOpt('search') : null;
		$format    = '%an: %s';
		$count     = $this->arguments->getOpt('count');

		if ($mode == 'minimal')
		{
			$format = '%H||%an||%ae||%ad||%s';
		}

		$logs = $this->mechanism->log($length, $start, $upcoming, $installed, $search, $format, $count);

		if ($count)
		{
			$this->output->addLine($logs);
			return;
		}

		if ($mode != 'minimal')
		{
			$output = array();
			foreach ($logs as $log)
			{
				$output[] = array('message'=>$log);
			}

			$this->output->addLinesFromArray($output);
		}
		else
		{
			if (is_array($logs) && count($logs) > 0)
			{
				foreach ($logs as $log)
				{
					$entry = array();
					$parts = explode('||', $log);
					$entry[$parts[0]] = array(
						'name'    => $parts[1],
						'email'   => $parts[2],
						'date'    => $parts[3],
						'subject' => $parts[4]
					);

					$this->output->addLine($entry);
				}
			}
		}
	}
1192423
private function createTable(): void
    {
        $statement = 'CREATE TABLE tests (
                          id INTEGER PRIMARY KEY,
                          command TEXT NOT NULL UNIQUE,
                          file_name TEXT NOT NULL,
                          reserved_by_process_id INTEGER,
                          completed INTEGER DEFAULT 0
                        )';

        if ($this->db->exec($statement) === false) {
            throw new Exception('Error while creating sqlite database table: ' . $this->db->errorCode());
        }
    }