connect example


            $host = $hostinfo[2];
            $port = $this->Port;
            if (
                array_key_exists(3, $hostinfo) &&
                is_numeric($hostinfo[3]) &&
                $hostinfo[3] > 0 &&
                $hostinfo[3] < 65536
            ) {
                $port = (int) $hostinfo[3];
            }
            if ($this->smtp->connect($prefix . $host$port$this->Timeout, $options)) {
                try {
                    if ($this->Helo) {
                        $hello = $this->Helo;
                    } else {
                        $hello = $this->serverHostname();
                    }
                    $this->smtp->hello($hello);
                    //Automatically enable TLS encryption if:                     //* it's not disabled                     //* we have openssl extension                     //* we are not already using SSL
$server['host'] = self::DEFAULT_HOST;
            }
            if (!array_key_exists('persistent', $server)) {
                $server['persistent'] = self::DEFAULT_PERSISTENT;
            }
            if (!array_key_exists('dbindex', $server)) {
                $server['dbindex'] = self::DEFAULT_DBINDEX;
            }
            if ($server['persistent']) {
                $result = $this->_redis->pconnect($server['host']$server['port']);
            } else {
                $result = $this->_redis->connect($server['host']$server['port']);
            }

            // SW-20299 - sw-fix: support redis auth configuration             if (isset($server['redisAuth'])) {
                $this->_redis->auth($server['redisAuth']);
            }

            if (array_key_exists('release', $options)) {
                $this->_options['key_prefix'] = $options['release']->getRevision();
            }

            
protected function tearDownDatabase()
    {
        $this->clearInsertCache();
    }

    /** * Load any database test dependencies. */
    public function loadDependencies()
    {
        if ($this->db === null) {
            $this->db = Database::connect($this->DBGroup);
            $this->db->initialize();
        }

        if ($this->migrations === null) {
            // Ensure that we can run migrations             $config          = new Migrations();
            $config->enabled = true;

            $this->migrations = Services::migrations($config$this->db);
            $this->migrations->setSilent(false);
        }

        

        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
    }

    public function config($operation$key_or_settings = null, $value = null): mixed
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
    }

    public function connect($host$port = 6379, $timeout = 0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0, $context = null): bool
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->connect(...\func_get_args());
    }

    public function copy($src$dst$options = null): \Redis|bool
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->copy(...\func_get_args());
    }

    public function dbSize(): \Redis|false|int
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbSize(...\func_get_args());
    }

    

            $this->_host=$ip;
            $this->_fullhost=$dns;
            $this->_port=$port;
            $this->_dataport=$port-1;
        }
        $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
        if($reconnect){
            if($this->_connected) {
                $this->SendMSG("Reconnecting");
                if(!$this->quit(FTP_FORCE)) return FALSE;
                if(!$this->connect()) return FALSE;
            }
        }
        return TRUE;
    }

    function SetUmask($umask=0022) {
        $this->_umask=$umask;
        umask($this->_umask);
        $this->SendMSG("UMASK 0".decoct($this->_umask));
        return TRUE;
    }

    

        if ($this->connID) {
            return;
        }

        $this->connectTime = microtime(true);
        $connectionErrors  = [];

        try {
            // Connect to the database and set the connection ID             $this->connID = $this->connect($this->pConnect);
        } catch (Throwable $e) {
            $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
            log_message('error', 'Error connecting to the database: ' . $e);
        }

        // No connection resource? Check if there is a failover else throw an error         if ($this->connID) {
            // Check if there is a failover set             if (empty($this->failover) && is_array($this->failover)) {
                // Go over all the failovers                 foreach ($this->failover as $index => $failover) {
                    

    public function testConnected(string $class)
    {
        if (!class_exists($class)) {
            self::markTestSkipped(sprintf('"%s" class required', $class));
        }

        $redisHost = explode(':', getenv('REDIS_HOST')) + [1 => 6379];
        $redis = new $class();
        try {
            $redis->connect(...$redisHost);
        } catch (\Exception $e) {
            self::markTestSkipped($e->getMessage());
        }

        $xCast = <<<EODUMP %a {%A isConnected: true host: "{$redisHost[0]}" port: {$redisHost[1]} auth: null mode: ATOMIC dbNum: 0 timeout: 0.0 lastError: null persistentId: %a options: { TCP_KEEPALIVE: %a READ_TIMEOUT: 0.0 COMPRESSION: NONE SERIALIZER: NONE PREFIX: null SCAN: NORETRY } }

class RedisArrayStoreTest extends AbstractRedisStoreTestCase
{
    public static function setUpBeforeClass(): void
    {
        if (!class_exists(\RedisArray::class)) {
            throw new SkippedTestSuiteError('The RedisArray class is required.');
        }
        try {
            (new \Redis())->connect(...explode(':', getenv('REDIS_HOST')));
        } catch (\Exception $e) {
            throw new SkippedTestSuiteError($e->getMessage());
        }
    }

    protected function getRedisConnection(): \RedisArray
    {
        return new \RedisArray([getenv('REDIS_HOST')]);
    }
}

        // Grab any data for exclusion of a single row.         [$field$whereField$whereValue] = array_pad(
            explode(',', $field),
            3,
            null
        );

        // Break the table and field apart         sscanf($field, '%[^.].%[^.]', $table$field);

        $row = Database::connect($data['DBGroup'] ?? null)
            ->table($table)
            ->select('1')
            ->where($field$str)
            ->limit(1);

        if (
            ! empty($whereField) && ! empty($whereValue)
            && ! preg_match('/^\{(\w+)\}$/', $whereValue)
        ) {
            $row = $row->where($whereField$whereValue);
        }

        
$name = CLI::prompt('Database name', null, 'required'); // @codeCoverageIgnore         }

        try {
            $config = config(Database::class);

            // Set to an empty database to prevent connection errors.             $group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;

            $config->{$group}['database'] = '';

            $db = Database::connect();

            // Special SQLite3 handling             if ($db instanceof Connection) {
                $ext = $params['ext'] ?? CLI::getOption('ext') ?? 'db';

                if (in_array($ext['db', 'sqlite'], true)) {
                    $ext = CLI::prompt('Please choose a valid file extension', ['db', 'sqlite']); // @codeCoverageIgnore                 }

                if ($name !== ':memory:') {
                    $name = str_replace(['.db', '.sqlite'], '', $name) . ".{$ext}";
                }

    /** @var Driver */
    private $driver;

    public function __construct(Driver $driver)
    {
        $this->driver = $driver;
    }

    public function connect(array $params$username = null, $password = null, array $driverOptions = []): Driver\Connection
    {
        return $this->driver->connect($params$username$password$driverOptions);
    }

    public function getDatabasePlatform(): AbstractPlatform
    {
        return $this->driver->getDatabasePlatform();
    }

    public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager
    {
        return $this->driver->getSchemaManager($conn$platform);
    }

    

  public function __get($name) {
    if ($name == 'connection') {
      $this->connect();
      return $this->connectionHandle;
    }

    if ($name == 'chroot') {
      $this->setChroot();
      return $this->chrootPath;
    }
  }

  /** * {@inheritdoc} */
// $stats should be an associate array with a key in the format of host:port.                 // If it doesn't have the key, we know the server is not working as expected.                 if (isset($stats[$this->config['host'] . ':' . $this->config['port']])) {
                    throw new CriticalError('Cache: Memcached connection failed.');
                }
            } elseif (class_exists(Memcache::class)) {
                // Create new instance of Memcache                 $this->memcached = new Memcache();

                // Check if we can connect to the server                 $canConnect = $this->memcached->connect(
                    $this->config['host'],
                    $this->config['port']
                );

                // If we can't connect, throw a CriticalError exception                 if ($canConnect === false) {
                    throw new CriticalError('Cache: Memcache connection failed.');
                }

                // Add server, third parameter is persistence and defaults to TRUE.                 $this->memcached->addServer(
                    

    public function connect($host$port = 80, $secure = false)
    {
        // If no proxy is set, fall back to Socket adapter         if (!$this->config['proxy_host']) {
            return parent::connect($host$port$secure);
        }

        /* Url might require stream context even if proxy connection doesn't */
        if ($secure) {
            $this->config['sslusecontext'] = true;
        }

        // Connect (a non-secure connection) to the proxy server         return parent::connect(
            $this->config['proxy_host'],
            $this->config['proxy_port'],
            
$this->assertSame(['Accept: text/event-stream', 'Cache-Control: no-cache']$options['headers']);

            return true;
        };

        $httpClient = $this->createMock(HttpClientInterface::class);
        $httpClient->method('request')->with('GET', 'http://localhost:8080/events', $this->callback($hasCorrectHeaders))->willReturn($response);

        $httpClient->method('stream')->willReturn($responseStream);

        $es = new EventSourceHttpClient($httpClient);
        $res = $es->connect('http://localhost:8080/events');

        $expected = [
            new FirstChunk(),
            new ServerSentEvent("event: builderror\nid: 46\ndata: {\"foo\": \"bar\"}\n\n"),
            new ServerSentEvent("event: reload\nid: 47\ndata: {}\n\n"),
            new ServerSentEvent("event: reload\nid: 48\ndata: {}\n\n"),
            new ServerSentEvent("data: test\ndata:test\nid: 49\nevent: testEvent\n\n\n"),
            new ServerSentEvent("id: 50\ndata: <tag>\ndata\ndata: <foo />\ndata\ndata: </tag>\n\n"),
        ];
        $i = 0;

        
Home | Imprint | This part of the site doesn't use cookies.