use MIME::Base64 ();
use Storable;
use Data::Dumper;
-use Hash::Merge;
+use Catalyst::Utils;
use YAML;
use Cwd qw( abs_path );
'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/
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];
+ }
}
$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 {