Пример #1
0
 /**
  * Get the DSN representation of the options given
  *
  * @param Options $options
  *
  * @return string
  */
 protected function getDSN(Options $options)
 {
     $extra = $options->getExtraOptions();
     $dsnParts = array();
     $dsnParts[] = "host={$options->getHost()}";
     $dsnParts[] = "port={$options->getPort()}";
     if ($options->getDatabaseName() !== null) {
         $dsnParts[] = "dbname={$options->getDatabaseName()}";
     }
     if (array_key_exists('unix_socket', $extra) === true) {
         $dsnParts[] = "unix_socket={$extra['unix_socket']}";
     }
     if (array_key_exists('charset', $extra) === true) {
         $dsnParts[] = "charset={$extra['charset']}";
     }
     return 'mysql:' . implode(';', $dsnParts);
 }