@param bool $isInteractive

@throws DatabaseConnectionException

@return bool
505096
protected function reconcileDatabaseConfiguration($isInteractive)
    {
        $db = $this->app['db'];
        $confirmMessage = 'Continue with these database settings?';
        $hasSqliteFile = $this->app['filesystem']->has('app://database/bolt.db');
        $platform = $this->app['config']->get('general/database/driver');
        $isSqlite = (bool) strpos($platform, 'sqlite');
        $ask = false;
        $note = [];

        if ($isSqlite && !$hasSqliteFile) {
            $this->isDbSetup = false;
            $note[] = 'Your database is configured as Sqlite, but does not exist yet.';
            $note[] = 'This might not be your intended configuration.';
            $ask = true;
        }
        if ($isSqlite && $hasSqliteFile) {
            $this->isDbSetup = true;
            if (empty($db->getSchemaManager()->listTableNames())) {
                $this->isDbSetup = false;
                $note[] = 'Your database is configured as Sqlite, but is empty.';
                $note[] = 'This might not be your intended database.';
                $ask = true;
            }
        }
        try {
            if (!$isSqlite) {
                $db->connect();
                $this->isDbSetup = true;
            }
        } catch (DatabaseConnectionException $e) {
            $this->isDbSetup = false;
            $note[] = 'Can not connect to your database as configured';
            $ask = true;
            if ($this->io->isVeryVerbose()) {
                throw $e;
            }
        }

        if ($ask && $isInteractive) {
            $this->step(++$this->step, 'Checking Database Configuration');
            $this->io->note($note);
            $confirm = $this->io->confirm($confirmMessage, false);
            if ($confirm === false) {
                $this->io->note([
                    'Further database checks will be skipped this time!',
                    'Please update the "database" section in your config.yml file',
                ]);
            }

            return $this->isDbSetup = $confirm;
        }

        return true;
    }
740452
public function select($database)
	{
		$this->connect();

		if (!$database)
		{
			return false;
		}

		if (!$this->connection->select_db($database))
		{
			throw new ConnectionFailureException('Could not connect to database.');
		}

		return true;
	}
755123
public function isConnected()
    {
        if ($this->_connection === null) {
            $connected = false;
        } else {
            try {
                $connected = $this->_connection->query('SELECT 1');
            } catch (PDOException $e) {
                $connected = false;
            }
        }

        return (bool)$connected;
    }
205084
public static function isConnected() {
		return self::$db !== null && (self::$db instanceof Database) && self::$db->isConnected ();
	}
1297818
public function doQuery($sql, $isExecute = false, $method = 'fetch', $fetchMode = null, $forRead = null){
        if ($forRead || $forRead === null && $this->db->getSchema()->isReadQuery($sql)) {
            $pdo = $this->db->getSlavePdo();
        } else {
            $pdo = $this->db->getMasterPdo();
        }
        return $pdo->doQuery($sql, $isExecute, $method, $fetchMode);
    }
959666
public function onPlayerConnect($login, $isSpectator = false, $dispatch = true)
    {
        try {
            $playerData = $this->playerStorage->getPlayerInfo($login);
        } catch (\Exception $e) {
            // TODO log that player disconnected very fast.
            return;
        }

        $this->playerStorage->onPlayerConnect($playerData);

        if ($dispatch) {
            $this->dispatch(__FUNCTION__, [$playerData]);
        }
    }
42498
public function connection($config = null, $forceConnect = false)
    {

        if ($this->connection && !$forceConnect) {
            return $this->connection;
        }

        !isset($config) || $this->config($config);

        $ref = new \ReflectionClass($this->getHandler());

        try {
            /** @var \PDO $connection */
            $this->connection = $ref->newInstanceArgs([
                $this->getConnectionString(),
                $this->getUser(),
                $this->getPassword(),
                $this->getHandlerOptions()
            ]);
        } catch (\PDOException $e) {
            throw new DatabaseException($e->getMessage());
        }

        return $this->connection;
    }
466094
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[SourceTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . SourceTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(SourceTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = 'id';
        }
        if ($this->isColumnModified(SourceTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = 'title';
        }
        if ($this->isColumnModified(SourceTableMap::COL_HOST)) {
            $modifiedColumns[':p' . $index++]  = 'host';
        }
        if ($this->isColumnModified(SourceTableMap::COL_ENDPOINT)) {
            $modifiedColumns[':p' . $index++]  = 'endpoint';
        }
        if ($this->isColumnModified(SourceTableMap::COL_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'created_at';
        }
        if ($this->isColumnModified(SourceTableMap::COL_UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'updated_at';
        }

        $sql = sprintf(
            'INSERT INTO source (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'id':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'title':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                    case 'host':
                        $stmt->bindValue($identifier, $this->host, PDO::PARAM_STR);
                        break;
                    case 'endpoint':
                        $stmt->bindValue($identifier, $this->endpoint, PDO::PARAM_STR);
                        break;
                    case 'created_at':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                    case 'updated_at':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
945365
public function db_connect($persistent = FALSE)
	{
		$this->conn_id = ($persistent)
				? mssql_pconnect($this->hostname, $this->username, $this->password)
				: mssql_connect($this->hostname, $this->username, $this->password);

		if ( ! $this->conn_id)
		{
			return FALSE;
		}

		// ----------------------------------------------------------------

		// Select the DB... assuming a database name is specified in the config file
		if ($this->database !== '' && ! $this->db_select())
		{
			return ($this->db_debug === TRUE)
				? $this->display_error('db_unable_to_select', $this->database)
				: FALSE;
		}

		// Determine how identifiers are escaped
		$query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi');
		$query = $query->row_array();
		$this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi'];
		$this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']');

		return $this->conn_id;
	}
808093
public function isActive(RolloutAbstract $rollout, DeterminableUserInterface $user = null)
    {
        
        if (100 === $this->getPercentage()) {
            return true;
        }
        
        if (!$user instanceof DeterminableUserInterface) {
            return false;
        }
        
        $userId = $user->getId();
        
        if (true === $this->isUserInPercentage($userId)
            || true === $this->isUserInActiveUsers($userId)
            || true === $this->isUserInActiveRole($user, $rollout)
            || true === $this->isUserInActiveGroup($user, $rollout)
        ) {
            return true;
        }
            
        
        return false;
    }
916734
func IsInteractive(ctx context.Context) bool {
	bv, ok := ctx.Value(ctxKeyInteractive).(bool)
	if !ok {
		return true
	}
	return bv
}
165476
protected function _isActionMapped()
    {
        if (!empty($this->dispatchComponents)) {
            foreach ($this->dispatchComponents as $component => $enabled) {
                if (empty($enabled)) {
                    continue;
                }

                // Skip if isActionMapped isn't defined in the Component
                if (!method_exists($this->{$component}, 'isActionMapped')) {
                    continue;
                }

                // Skip if the action isn't mapped
                if (!$this->{$component}->isActionMapped()) {
                    continue;
                }

                // Skip if execute isn't defined in the Component
                if (!method_exists($this->{$component}, 'execute')) {
                    continue;
                }

                // Return the component instance.
                return $this->{$component};
            }
        }

        return false;
    }
822428
public function hasDatabase()
    {
        try {
            $pdo = new \PDO(
                'mysql:host='.$this->txpcfg['host'].';dbname='.$this->txpcfg['db'],
                $this->txpcfg['user'],
                $this->txpcfg['pass']
            );
        } catch (\PDOException $e) {
            $pdo = false;
        }

        if ($pdo === false) {
            throw new \InvalidArgumentException(
                'Unable connect to Textpattern database: '.$this->txpcfg['db'].'@'.$this->txpcfg['host']
            );
        }

        if (!$pdo->prepare('SHOW TABLES LIKE ?')->execute(array($this->txpcfg['table_prefix'] . 'textpattern'))) {
            throw new \InvalidArgumentException('Textpattern is not installed');
        }
    }
322266
protected function reconcileDatabaseSchema(InputInterface $input, OutputInterface $output)
    {
        if ($this->isDbSetup === false) {
            return true;
        }
        $this->step(++$this->step, 'Checking Database Schema');
        $command = $this->getApplication()->find('database:check');
        $buffer = $this->getBufferedOutput($output, OutputInterface::VERBOSITY_QUIET);
        $subInput = new ArrayInput([
            '--no-interaction' => true,
        ]);

        $result = $command->run($subInput, $buffer);
        $this->writeBufferedOutput($buffer, $result);
        if ($result === 0) {
            return true;
        }

        $this->step(++$this->step, 'Updating Database Schema');
        $command = $this->getApplication()->find('database:update');
        $subInput = new ArrayInput([]);
        $subInput->setInteractive(!$input->isInteractive());

        $result = $command->run($subInput, $output);

        return $result === 0;
    }
908217
public function connect(): DatabaseConnection
    {
        if (null !== $this->pdo) {
            return $this;
        }

        try {
            $pdoCreator = $this->getPdoCreator();
            $this->pdo  = $pdoCreator($this->configuration);
            $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
            if ($this->configuration->hasInitialQuery()) {
                $this->pdo->query($this->configuration->getInitialQuery());
            }
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }

        return $this;
    }
725675
public function isTransient($className)
    {
        if (!\class_exists($className)) {
            return false;
        }

        $instances = \class_implements($className);
        if ($instances === false) {
            return false;
        }

        if (!\in_array(EntityInterface::class, $instances)) {
            return false;
        }
//        if (!\in_array(DatabaseEntityInterface::class, $instances)) {
//            return false;
//        }

        return true;
    }
26204
public function isConnected()
    {
        return $this->synchronized(function ($self) {
            return $self->applicationState->equals(ApplicationStateKeys::get(ApplicationStateKeys::INITIALIZATION_SUCCESSFUL));
        }, $this);
    }