[siesta-commit] siesta/lib/Siesta Config.pm,1.5,1.6

[prev] [thread] [next] [lurker] [Date index for 2002/09/02]

From: muttley
Subject: [siesta-commit] siesta/lib/Siesta Config.pm,1.5,1.6
Date: 12:44 on 02 Sep 2002
Update of /cvsroot/siesta/siesta/lib/Siesta
In directory usw-pr-cvs1:/tmp/cvs-serv25041

Modified Files:
	Config.pm 
Log Message:
getting config working


Index: Config.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Config.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Config.pm	1 Sep 2002 12:09:16 -0000	1.5
+++ Config.pm	2 Sep 2002 11:44:45 -0000	1.6
@@ -4,6 +4,7 @@
 use vars qw( $DBFILE $ARCHIVE_PATH );
 require Ima::DBI;
 use base qw(Ima::DBI);
+use Data::Dumper;
 
 $DBFILE = '/home/simon/projects/siesta/siesta.db';
 $ARCHIVE_PATH = '/home/richardc/lab/siesta/archive';
@@ -18,8 +19,12 @@
 	my ($self, $id, $namespace, $key) = @_;
 	my $sth = $self->sql_get;
 
-	$sth->execute(qw($id $namespace $key));
-	return $sth->fetch;
+	my @vals = ($id, $namespace, $key);
+	$sth->execute(@vals);
+
+	my $values = $sth->fetch;
+	$sth->finish;
+	return $values->[0] if (defined $values);
 }
 
 
@@ -30,14 +35,21 @@
 	
 	# are we inserting or updating?
 	my $sth;
-	unless (defined $self->get($namespace, $key)) {
-		$sth = $self->sql_insert()
+	my $current = $self->get($id, $namespace, $key);
+	unless ($current) {
+		$sth = $self->sql_insert();
+		return undef unless defined $sth;
+		my @values = ($id, $namespace, $key, $value);
+		return $sth->execute(@values);
+
 	} else {
-		$sth = $self->sql_update()
+		$sth = $self->sql_update();
+		return undef unless defined $sth;
+		my @values = ($value, $id, $namespace, $key);
+		return $sth->execute(@values);
+
 	}
 
-	return undef unless defined $sth;
-	return $sth->execute(qw($id $namespace $key $value));
 
 }
 



Generated at 13:57 on 01 Jul 2004 by mariachi 0.52