public function isLinked(string $host = null): bool
    {
        // link exists?
        // e.g: isLinked('localhost')
        if ($host && isset($this->links[$host])) {
            return ($this->links[$host]->status() === Link::STATUS_CONNECTED);
        }

        // without master/slave directives
        // e.g: isLinked()
        if (true !== $this->config->get('sharding')) {
            foreach ($this->links as $link) {
                return ($link->status() === Link::STATUS_CONNECTED);
            }
        }

        // with master/slave directives, check by host
        switch (trim((string) $host)) {
            // e.g: isLinked(), isLinked('master')
            case '':
            case Link::TYPE_MASTER:
                foreach ($this->links as $link) {
                    if ($link->getType() == Link::TYPE_MASTER) {
                        return ($link->status() === Link::STATUS_CONNECTED);
                    }
                }
                break;
            // e.g: isLinked('slave1.mysql.local'), isLinked('slave')
            case Link::TYPE_SLAVE:
                foreach ($this->links as $link) {
                    if ($link->getType() == Link::TYPE_SLAVE) {
                        return ($link->status() === Link::STATUS_CONNECTED);
                    }
                }
                break;
        }

        return false;
    }
public function isLinked(string $host = null): bool
    {
        // link exists?
        // e.g: isLinked('localhost')
        if ($host && isset($this->links[$host])) {
            return ($this->links[$host]->status() === Link::STATUS_CONNECTED);
        }

        // without master/slave directives
        // e.g: isLinked()
        if (true !== $this->config->get('sharding')) {
            foreach ($this->links as $link) {
                return ($link->status() === Link::STATUS_CONNECTED);
            }
        }

        // with master/slave directives, check by host
        switch (trim((string) $host)) {
            // e.g: isLinked(), isLinked('master')
            case '':
            case Link::TYPE_MASTER:
                foreach ($this->links as $link) {
                    if ($link->getType() == Link::TYPE_MASTER) {
                        return ($link->status() === Link::STATUS_CONNECTED);
                    }
                }
                break;
            // e.g: isLinked('slave1.mysql.local'), isLinked('slave')
            case Link::TYPE_SLAVE:
                foreach ($this->links as $link) {
                    if ($link->getType() == Link::TYPE_SLAVE) {
                        return ($link->status() === Link::STATUS_CONNECTED);
                    }
                }
                break;
        }

        return false;
    }
public function isLinked ( string $ host = null ) : bool { // link exists? // e.g: isLinked('localhost') if ( $ host && isset ( $ this -> links [ $ host ] ) ) { return ( $ this -> links [ $ host ] -> status ( ) === Link :: STATUS_CONNECTED ) ; } // without master/slave directives // e.g: isLinked() if ( true !== $ this -> config -> get ( 'sharding' ) ) { foreach ( $ this -> links as $ link ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } // with master/slave directives, check by host switch ( trim ( ( string ) $ host ) ) { // e.g: isLinked(), isLinked('master') case '' : case Link :: TYPE_MASTER : foreach ( $ this -> links as $ link ) { if ( $ link -> getType ( ) == Link :: TYPE_MASTER ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } break ; // e.g: isLinked('slave1.mysql.local'), isLinked('slave') case Link :: TYPE_SLAVE : foreach ( $ this -> links as $ link ) { if ( $ link -> getType ( ) == Link :: TYPE_SLAVE ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } break ; } return false ; }
Is linked.
@param  string|null $host
@return bool
Is linked .