Skip to content

Commit

Permalink
[mysql] Connect via socket
Browse files Browse the repository at this point in the history
Add connection option to connect to a server via a (non-default) socket
on the filesystem.
  • Loading branch information
avuserow committed Feb 28, 2015
1 parent 1912800 commit 21fdbe8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ and interpolating strings.

my $dbh = DBIish.connect('mysql', :host<db02.yourdomain.com>, :port(3306),
:database<blerg>, :user<myuser>, :$password);
# Or via socket:
my $dbh = DBIish.connect('mysql', :socket<mysql.sock>,
:database<blerg>, :user<myuser>, :$password);

=head1 TESTING

Expand Down
3 changes: 2 additions & 1 deletion lib/DBDish/mysql.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ class DBDish::mysql:auth<mberends>:ver<0.0.1> {
my $host = %params<host> // 'localhost';
my $port = (%params<port> // 0).Int;
my $database = %params<database> // 'mysql';
my $socket = %params<socket> // OpaquePointer;
# real_connect() returns either the same client pointer or null
my $result = mysql_real_connect( $mysql_client, $host,
$user, $password, $database, $port, OpaquePointer, 0 );
$user, $password, $database, $port, $socket, 0 );
my $error = mysql_error( $mysql_client );
my $connection;
if $error eq '' {
Expand Down

0 comments on commit 21fdbe8

Please sign in to comment.