[Affelio-cvs 228] CVS update: affelio/lib

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 6月 28日 (火) 10:27:24 JST


Index: affelio/lib/Affelio.pm
diff -u affelio/lib/Affelio.pm:1.8 affelio/lib/Affelio.pm:1.9
--- affelio/lib/Affelio.pm:1.8	Tue Jun 28 02:50:26 2005
+++ affelio/lib/Affelio.pm	Tue Jun 28 10:27:24 2005
@@ -4,7 +4,7 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: Affelio.pm,v 1.8 2005/06/27 17:50:26 slash5234 Exp $
+# $Id: Affelio.pm,v 1.9 2005/06/28 01:27:24 slash5234 Exp $
 
 package Affelio;
 {
@@ -169,6 +169,8 @@
     sub openDB{
 	my $self = shift;
 
+	undef($self->{db});
+
 	#Load username and password
 	my $DBConfig = Config::Tiny->new();
 	$DBConfig = Config::Tiny->read("$self->{site__user_dir}/db.cfg");
@@ -180,15 +182,21 @@
 	my $db_hostname = $DBConfig->{db}->{hostname};
 	my $db_port = $DBConfig->{db}->{port};
 
-	###MySQL
 	if($db_type eq "mysql"){
+	    
 	    my $dsn = "DBI:mysql:$db_dbname:$db_hostname:$db_port";
-	    $self->{db} = DBI->connect($dsn, $db_username, $db_password) or die "Cannot connect to DB: " . $DBI::errstr;
+	    $self->{db} = DBI->connect($dsn, $db_username, $db_password) or die("Cannot connect to MySQL: " . $DBI::errstr);
+
+	}elsif ($db_type eq "sqlite"){
+
+	    $self->{db} = DBI->connect("dbi:SQLite:dbname=$self->{site__user_dir}/DB.sqlite", "", "") or die("Cannot connect to SQLite: " . $DBI::errstr);
+
+	}else{
+	    die("DB type not specified");
 	}
-	###SQLite
-	if($db_type eq "sqlite"){
-	    debug_print("Affelio::openDB: [$self->{site__user_dir}/DB.sqlite]");
-	    $self->{db} = DBI->connect("dbi:SQLite:dbname=$self->{site__user_dir}/DB.sqlite", "", "") or die "Cannot connect to DB: " . $DBI::errstr;
+
+	if(!defined($self->{db})){
+	    die("DB handle error: This error is very weird.");
 	}
 
 	$self->{db}->{RaiseError} = 1;


Affelio-cvs メーリングリストの案内
Back to archive index