]> Frank Brehm's Git Trees - books.git/commitdiff
show_sessions.pl an neue Konfiguration angepaßt
authorFrank Brehm <frank@brehm-online.com>
Sun, 5 Apr 2009 11:31:19 +0000 (11:31 +0000)
committerFrank Brehm <frank@brehm-online.com>
Sun, 5 Apr 2009 11:31:19 +0000 (11:31 +0000)
bin/show_sessions.pl
lib/FrBr/Books/Db.pm

index 5e1e3411ba748ba3ab6921d2e0aeb07e6f5cd13e..bd4bb378e51c185afcce68671e3b635f6f993687 100755 (executable)
@@ -14,7 +14,7 @@ use FrBr::Books::Db;
 use MIME::Base64 ();
 use Storable;
 use Data::Dumper;
-use Hash::Merge;
+use Catalyst::Utils;
 use YAML;
 use Cwd qw( abs_path );
 
@@ -30,18 +30,14 @@ my $attrs    = {
     'RaiseError' => 0,
 };
 
-my $dbconf = {
-    'host'  => 'localhost',
-    'port'  => 3306,
-    'db'    => 'books',
-    'user'  => 'books',
-    'pwd'   => 'uhu',
-};
-config();
+my $dbuser = 'books';
+my $dbpwd  = '';
 
-my $dsn = sprintf( 'DBI:mysql:database=%s;host=%s%s', $dbconf->{'db'}, $dbconf->{'host'}, $dbconf->{'port'} == 3306 ? '' : ( ';port=' . $dbconf->{'port'} ) );
+my $dsn = 'DBI:mysql:database=books;host=localhost';
 
-my $schema = FrBr::Books::Db->connect( $dsn, $dbconf->{'user'}, $dbconf->{'pwd'}, $attrs );
+config();
+
+my $schema = FrBr::Books::Db->connect( $dsn, $dbuser, $dbpwd, $attrs );
 
 my @all_items = $schema->resultset('Session')->search( undef, {
                 'columns' => [ qw/
@@ -86,18 +82,19 @@ sub config {
 
     my $conf;
     if ( $cnf_local ) {
-        Hash::Merge::set_behavior( 'RIGHT_PRECEDENT' );
-        $conf = Hash::Merge::merge( $cnf_normal, $cnf_local );
+        $conf = Catalyst::Utils::merge_hashes( $cnf_normal, $cnf_local );
     }
     else {
         $conf = $cnf_normal;
     }
 
-    $dbconf->{'host'} = $conf->{'database'}{'host'} if $conf->{'database'}{'host'};
-    $dbconf->{'port'} = to_int( $conf->{'database'}{'port'} ) if $conf->{'database'}{'port'} and to_int( $conf->{'database'}{'port'} );
-    $dbconf->{'db'}   = $conf->{'database'}{'schema'} if $conf->{'database'}{'schema'};
-    $dbconf->{'user'} = $conf->{'database'}{'user'} if $conf->{'database'}{'user'};
-    $dbconf->{'pwd'}  = $conf->{'database'}{'passwd'} if $conf->{'database'}{'passwd'};
+    if ( $conf->{'Model::Schema'}{'connect_info'} ) {
+        my $c = $conf->{'Model::Schema'}{'connect_info'};
+        $dsn    = $c->[0];
+        $dbuser = $c->[1];
+        $dbpwd  = $c->[2];
+        $attrs  = $c->[3];
+    }
 
 }
 
index 1ceec654fc0fff1e54b70316a3fe352fe147ef76..7041a1aa02f455ccee4a9edf4415b1a78ad7cc1f 100644 (file)
@@ -26,9 +26,8 @@ sub connect {
     $schema->storage->sql_maker->quote_char( [qw/` `/] );
     $schema->storage->sql_maker->name_sep('.');
 
-    my $SQL = "SET NAMES 'utf-8'";
+    my $SQL = "SET NAMES 'utf8'";
     warn $SQL . ";\n" if $schema->storage->debug();
-    warn $SQL . ";\n";
 
     $schema->storage->dbh_do(
         sub {