Illuminate\Database\Connection::getReadPdo PHP Метод

getReadPdo() публичный Метод

Get the current PDO connection used for reading.
public getReadPdo ( ) : PDO
Результат PDO
    public function getReadPdo()
    {
        if ($this->transactions >= 1) {
            return $this->getPdo();
        }
        if ($this->readPdo instanceof Closure) {
            return $this->readPdo = call_user_func($this->readPdo);
        }
        return $this->readPdo ?: $this->getPdo();
    }

Usage Example

Пример #1
0
 /**
  * Prepare the read write mode for database connection instance.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @param  string  $type
  * @return \Illuminate\Database\Connection
  */
 protected function setPdoForType(Connection $connection, $type = null)
 {
     if ($type == 'read') {
         $connection->setPdo($connection->getReadPdo());
     } elseif ($type == 'write') {
         $connection->setReadPdo($connection->getPdo());
     }
     return $connection;
 }