Executes the task for MySQL databases.
481576
protected function _mysql()
	{
		$this->_msg('Creating admin tables', 0);
		$this->_status('');

		$ds = DIRECTORY_SEPARATOR;

		$files = array(
			'db-cache' => realpath(__DIR__) . $ds . 'default' . $ds . 'schema' . $ds . 'mysql' . $ds . 'cache.sql',
			'db-log' => realpath(__DIR__) . $ds . 'default' . $ds . 'schema' . $ds . 'mysql' . $ds . 'log.sql',
			'db-job' => realpath(__DIR__) . $ds . 'default' . $ds . 'schema' . $ds . 'mysql' . $ds . 'job.sql',
		);

		$this->_setup($files);
	}
291915
public function run()
	{
		// Lets make sure we have a database
		if (!$this->taskCreateDb()
				->host($this->host)
				->user($this->user)
				->pass($this->pass)
				->name($this->name)
				->dropTables(true)
			->run()->wasSuccessful()
		){
			throw new RuntimeException('We failed to create the db.');
		}

		// Do we need to uncompress it first?
		if (strpos($this->dump, '.gz') !== false)
		{
			// Create a temp dump file
			$temp_dump = tempnam(sys_get_temp_dir(), 'dump');

			// Decompress the dump file
			if ($fp_out = fopen($temp_dump, 'wb'))
			{
				if ($fp_in = gzopen($this->dump, 'rb'))
				{
					while (!gzeof($fp_in))
					{
						fwrite($fp_out, gzread($fp_in, 1024 * 512));
					}

					fclose($fp_in);
				}
				else
				{
					throw new RuntimeException
					(
						'Failed to open source dump file for reading.'
					);
				}

				gzclose($fp_out);
			}
			else
			{
				throw new RuntimeException
				(
					'Failed to open temp dump file for writing.'
				);
			}

			// Set the dump the deflated version
			$this->dump = $temp_dump;

			// Delete the temp later
			$delete_me = $this->dump;
		}

		// Construct the command to import the dump
		$cmd = 'mysql -h'.$this->host.' -u'.$this->user;
		if (!empty($this->pass)) $cmd .= ' -p'.$this->pass;
		$cmd .= ' '.$this->name.' < '.$this->dump;

		// Run the command
		if (!$this->taskExec($cmd)->run()->wasSuccessful())
		{
			throw new RuntimeException
			(
				'We failed to import your dump. '.
				'HINT: Is the `mysql` binary in your "PATH"?'
			);
		}

		// Delete the deflated temp dump file
		if (isset($delete_me))
		{
			$this->printTaskInfo('Deleting temp dump file.');
			if (!unlink($delete_me))
			{
				return Result::error($this, 'Couldn`t delete temp file.');
			}
		}

		// If we get to here assume everything worked
		return Result::success($this);
	}
1182808
public function execute() {
		$this->out(__d('cake_ldap', 'Synchronization with LDAP server in progress...'), 1, Shell::NORMAL);
		if ($this->QueuedTask->createJob('SyncEmployee', null, null, 'sync')) {
			$this->out(__d('cake_ldap', 'Synchronization with LDAP server set in queue successfully.'), 1, Shell::NORMAL);
		} else {
			$this->out('<error>' . __d('cake_ldap', 'Synchronization with LDAP server set in queue unsuccessfully.') . '</error>');
		}
	}
619196
public function run()
	{
		// Build the command to run
		$cmd = 'php ./vendor/interconnectit/search-replace-db/srdb.cli.php ';

		// Add the the db details
		$cmd .= '--host "'.$this->dbHost.'" ';
		$cmd .= '--user "'.$this->dbUser.'" ';
		$cmd .= '--pass "'.$this->dbPass.'" ';
		$cmd .= '--name "'.$this->dbName.'" ';

		// Add the search term and replacement
		$cmd .= '--search "'.$this->searchFor.'" ';
		$cmd .= '--replace "'.$this->replaceWith.'" ';

		// Provide a custom set of tables to search and replace
		if (!empty($this->tables))
		{
			if (is_array($this->tables))
			{
				$this->tables = implode(',', $this->tables);
			}

			$cmd .= '--tables "'.$this->tables.'" ';
		}

		// Provide a custom set of columns to search and replace
		if (!empty($this->columns))
		{
			if (is_array($this->columns))
			{
				$this->columns = implode(',', $this->columns);
			}

			$cmd .= '--include-cols "'.$this->columns.'" ';
		}

		// Are we using regular expressions
		if ($this->useRegx) $cmd .= '--regex ';

		// Is it a dry run or not
		if ($this->dryRun) $cmd .= '--dry-run ';

		// Tell the world whats happening
		$this->printTaskInfo('running <info>'.$cmd.'</info>');

		// Run the cmd
		$descriptorspec = [1 => ["pipe", "w"], 2 => ["pipe", "w"]];
		$process = proc_open($cmd, $descriptorspec, $pipes);
		if (is_resource($process))
		{
			$output = [];

			$output['stdout'] = stream_get_contents($pipes[1]);
			fclose($pipes[1]);

			$output['stderr'] = stream_get_contents($pipes[2]);
			fclose($pipes[2]);

			proc_close($process);
		}
		else
		{
			return Result::error($this, 'Failed to run the command!');
		}

		// Remove the strict standard error
		$regx = '/(PHP\s)?Strict Standards:\s+Declaration of icit_srdb_cli::log.*?\d+/';
		$output['stdout'] = trim(s::create($output['stdout'])->regexReplace($regx, ''));
		$output['stderr'] = trim(s::create($output['stderr'])->regexReplace($regx, ''));

		// Check for errors
		if (!empty($output['stderr']))
		{
			return Result::error($this, $output['stderr']);
		}

		// Split stdout to an array of lines
		$output = explode("\n", $output['stdout']);

		// Remove the last 2 lines from the output
		// While the search and replace might be done, other tasks may not be.
		// Thus we might give the wrong impression of being complete.
		$status = array_pop($output); array_pop($output);

		// Do we want to output all the results
		if ($this->verbose)
		{
			foreach ($output as $line)
			{
				$this->printTaskInfo($line);
			}
		}
		else
		{
			// We only need to output the last 4 lines
			foreach (array_slice($output, -4) as $line)
			{
				$this->printTaskInfo($line);
			}
		}

		// Return success of failure
		if ($status == 'And we\'re done!')
		{
			return Result::success($this);
		}
		else
		{
			return Result::error($this, $status);
		}
	}
329713
public function execute()
    {
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsEnabled` TINYINT(1)  UNSIGNED  NOT NULL  DEFAULT '1'  AFTER `seo_keywords`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsExpire` DATETIME  NULL  AFTER `commentsEnabled`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `type` ENUM('TEXT','AUDIO','VIDEO','PHOTO')  NOT NULL  DEFAULT 'PHOTO'  AFTER `slug`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `video_url` VARCHAR(255)  NULL  DEFAULT NULL  AFTER `image_id`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `audio_url` VARCHAR(255)  NULL  DEFAULT NULL  AFTER `video_url`;");
        $this->query("UPDATE `{{NAILS_DB_PREFIX}}blog_post` SET type = 'TEXT' WHERE image_id IS NULL;");
    }
580756
public function main()
    {
        // check to make sure task received all correct params
        $this->validate();

        $generatorConfig = $this->getGeneratorConfig();
        $totalNbFiles = 0;

        $dataModels = $this->getDataModels();
        $this->log('Generating PHP files...');

        foreach ($dataModels as $dataModel) {
            $this->log("Datamodel: " . $dataModel->getName(), Project::MSG_VERBOSE);

            foreach ($dataModel->getDatabases() as $database) {

                if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
                    $database->getPlatform()->setIdentifierQuoting(false);
                }

                $this->log(" - Database: " . $database->getName(), Project::MSG_VERBOSE);

                foreach ($database->getTables() as $table) {

                    if (!$table->isForReferenceOnly()) {

                        $nbWrittenFiles = 0;

                        $this->log("  + Table: " . $table->getName(), Project::MSG_VERBOSE);

                        // -----------------------------------------------------------------------------------------
                        // Create Peer, Object, and TableMap classes
                        // -----------------------------------------------------------------------------------------

                        // these files are always created / overwrite any existing files
                        foreach (array('peer', 'object', 'tablemap', 'query') as $target) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                            $nbWrittenFiles += $this->build($builder);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create [empty] stub Peer and Object classes if they don't exist
                        // -----------------------------------------------------------------------------------------

                        // these classes are only generated if they don't already exist
                        foreach (array('peerstub', 'objectstub', 'querystub') as $target) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                            $nbWrittenFiles += $this->build($builder, $overwrite = false);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create [empty] stub child Object classes if they don't exist
                        // -----------------------------------------------------------------------------------------

                        // If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.
                        if ($col = $table->getChildrenColumn()) {
                            if ($col->isEnumeratedClasses()) {
                                foreach ($col->getChildren() as $child) {
                                    foreach (array('queryinheritance') as $target) {
                                        if (!$child->getAncestor()) {
                                            continue;
                                        }
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $builder->setChild($child);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = true);
                                    }
                                    foreach (array('objectmultiextend', 'queryinheritancestub') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $builder->setChild($child);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = false);
                                    }
                                } // foreach
                            } // if col->is enumerated
                        } // if tbl->getChildrenCol


                        // -----------------------------------------------------------------------------------------
                        // Create [empty] Interface if it doesn't exist
                        // -----------------------------------------------------------------------------------------

                        // Create [empty] interface if it does not already exist
                        if ($table->getInterface()) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
                            $nbWrittenFiles += $this->build($builder, $overwrite = false);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create tree Node classes
                        // -----------------------------------------------------------------------------------------

                        if ($table->treeMode()) {
                            switch ($table->treeMode()) {
                                case 'NestedSet':
                                    foreach (array('nestedsetpeer', 'nestedset') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder);
                                    }
                                    break;

                                case 'MaterializedPath':
                                    foreach (array('nodepeer', 'node') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder);
                                    }

                                    foreach (array('nodepeerstub', 'nodestub') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = false);
                                    }
                                    break;

                                case 'AdjacencyList':
                                    // No implementation for this yet.
                                default:
                                    break;
                            }
                        } // if Table->treeMode()

                        // ----------------------------------
                        // Create classes added by behaviors
                        // ----------------------------------
                        if ($table->hasAdditionalBuilders()) {
                            foreach ($table->getAdditionalBuilders() as $builderClass) {
                                $builder = new $builderClass($table);
                                $builder->setGeneratorConfig($generatorConfig);
                                $nbWrittenFiles += $this->build($builder, isset($builder->overwrite) ? $builder->overwrite : true);
                            }
                        }

                        $totalNbFiles += $nbWrittenFiles;
                        if ($nbWrittenFiles == 0) {
                            $this->log("\t\t(no change)", Project::MSG_VERBOSE);
                        }
                    } // if !$table->isForReferenceOnly()

                } // foreach table

            } // foreach database

        } // foreach dataModel
        if ($totalNbFiles) {
            $this->log(sprintf("Object model generation complete - %d files written", $totalNbFiles));
        } else {
            $this->log("Object model generation complete - All files already up to date");
        }
    }
64198
protected function taskMysqlCommand()
    {
        $mysqlBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN);
        $dbHost   = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-host');
        $dbUser   = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-user');
        $dbPass   = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-password');

        $hostParts = explode(':', $dbHost);
        $dbPort    = null;
        if (count($hostParts) === 2) {
            $dbPort = array_pop($hostParts);
            $dbHost = array_pop($hostParts);
        }

        $createDatabase = $this->taskExec($mysqlBin);
        $createDatabase->option('-h', $dbHost);

        if ($dbPort !== null) {
            $createDatabase->option('-P', $dbPort);
        }

        $createDatabase->option('-u', $dbUser);
        if ($dbPass) {
            $createDatabase->option("-p$dbPass");
        }

        return $createDatabase;
    }
1296915
public function run()
    {

        // Check if we have the schedules, else,
        // insert them
        foreach ($this->schedule as $job) {

            if (! DB::table('schedules')->where('command', $job['command'])->first())
                DB::table('schedules')->insert($job);
        }
    }
1319921
async def execute(self, stmt, *args):
        
        with (await self.application.db.cursor()) as cur:
            await cur.execute(stmt, args)
236337
public function run( $dbtype )
	{
		foreach( $this->_tasks as $taskname => $task ) {
			$this->_runTasks( $dbtype, array( $taskname ) );
		}
	}
328688
public function execute()
    {
        if (!$this->isEmpty()) {
            $this->table->update($this->context + $this->values, $this->where)->run();
        }

        parent::execute();
    }
84756
public function run()
    {
        if (!App::environment('testing')) {
            DB::statement('SET FOREIGN_KEY_CHECKS=0');
        }
        DB::table(config('combine-core.tablePrefix', 'combine') . '_abilities')->truncate();
        DB::table(config('combine-core.tablePrefix', 'combine') . '_roles')->truncate();
        DB::table(config('combine-core.tablePrefix', 'combine') . '_teams')->truncate();
        DB::table('users')->truncate();
        if (!App::environment('testing')) {
            DB::statement('SET FOREIGN_KEY_CHECKS=1');
        }

        echo "Populating Roles ...\n";
        $this->roleModels = $this->populateRoles($this->roles);
        echo "Populating Abiltiies ...\n";
        $this->populateAbilities($this->abilities, $this->roleModels);
    }
110264
public function execute()
    {
        foreach ($this->getJobs() as $key => $job) {
            try {
                $this->console($job, $key + 1);
                $task = $this->createTask($job);
                $return = $task->run();
                $this->getAdapter()->history(HistoryInterface::STATUS_OK, $job, is_string($return) ? $return : null);
            } catch (\Exception $exc) {
                $this->log($job, $exc);
            }
        }

        $this->getAdapter()->finishProcessing($this->getJobs());
    }
1153274
public function execute() {
        if (!is_enabled_auth('db')) {
            mtrace('auth_db plugin is disabled, synchronisation stopped', 2);
            return;
        }

        $dbauth = get_auth_plugin('db');
        $config = get_config('auth_db');
        $trace = new \text_progress_trace();
        $update = !empty($config->updateusers);
        $dbauth->sync_users($trace, $update);
    }
1288597
public function run()
    {
        DB::table('languages')->delete();

        foreach ($this->langs() as $lang) {
            Language::create($lang);
        }
    }
54804
def execute_sql(self, sql):
        """"""
        cursor = self.get_cursor()
        cursor.execute(sql)
        return cursor
126577
private function execute()
    {
        $this->connect();
        try {
            $this->getSyntax();
            $this->read->execute();
            $this->result = $this->read->fetchAll();
        } catch (\PDOException $e) {
            $this->result = null;
            parent::error("<b>Erro ao Ler:</b> {$e->getMessage()}", $e->getCode());
        }

        parent::setDatabase(DATABASE);
    }