/**
  * @param string $sql
  * @param array  $params
  * @param array  $types
  *
  * @return array
  *
  * @throws \RuntimeException
  */
 public function queryAll($sql, array $params, array $types)
 {
     $shards = $this->getShards();
     if (!$shards) {
         throw new \RuntimeException("No shards found.");
     }
     $result = array();
     $oldDistribution = $this->getCurrentDistributionValue();
     foreach ($shards as $shard) {
         $this->conn->connect($shard['id']);
         foreach ($this->conn->fetchAll($sql, $params, $types) as $row) {
             $result[] = $row;
         }
     }
     if ($oldDistribution === null) {
         $this->selectGlobal();
     } else {
         $this->selectShard($oldDistribution);
     }
     return $result;
 }