/**
  * Set database name and optionally select that database.
  *
  * @param  string              $database_name
  * @param  bool|true           $select_database
  * @return $this
  * @throws ConnectionException
  */
 public function &setDatabaseName($database_name, $select_database = true)
 {
     if (empty($select_database) || $this->link->select_db($database_name)) {
         $this->database_name = $database_name;
     } else {
         throw new ConnectionException("Failed to select database '{$database_name}'");
     }
     return $this;
 }