Re: [Cgi-session-user] Trouble with C::S::SQLite
Brought to you by:
sherzodr
From: Puneet K. <pu...@ei...> - 2006-03-07 13:49:28
|
On Mar 7, 2006, at 1:39 AM, Sherzod Ruzmetov wrote: > That's the start, > > Now, instead of passing a database handle to CGI::Session->new(), why > don't you try to initialize it with a full datasource description? > well, if I change new CGI::Session("driver:sqlite", $sid, {Handle=>$DBH}) to either of the following two choices new CGI::Session("driver:sqlite", $sid, {Handle=>DBI->connect("dbi:SQLite:dbname=/path/to/my.db")}) new CGI::Session("driver:sqlite", $sid, {DataSource=>"dbi:SQLite:dbname=/path/to/my.db"}) The session value gets stored in the database alright, but I get the following error >> (in cleanup) Can't call method "commit" on unblessed reference at /usr/local/ActivePerl-5.8/lib/site_perl/5.8.7/CGI/Session/Driver/DBI.pm line 128 during global destruction. > >> -----Original Message----- >> From: cgi...@li... >> [mailto:cgi...@li...] On >> Behalf Of Puneet Kishor >> Sent: Monday, March 06, 2006 10:52 PM >> To: List - CGI-Session >> Cc: ro...@sa...; Mark Stosberg >> Subject: Re: [Cgi-session-user] Trouble with C::S::SQLite >> >> >> Ok, making progress. >> >> I modified the CGI/Session/Driver/sqlite.pm like so -- >> >> sub store { >> my $self = shift; >> my ($sid, $datastr) = @_; >> return $self->set_error("store(): usage error") unless $sid && >> $datastr; >> >> #my $dbh = $self->{Handle}; >> my $dbh = >> DBI->connect("dbi:SQLite:dbname=/path/to/my.db") or die "Db >> connect failed: $DBI::errstr"; >> my $sth = $dbh->prepare("SELECT id FROM " . >> $self->table_name . " >> WHERE id=?"); >> >> And it works just fine. My session value is stored in the sessions >> table, and reused properly. So, the error is in the way $dbh is being >> passed. I am using the following syntax in my calling script -- >> >> new CGI::Session("driver:sqlite", $sid, {Handle=>$dbh}) >> >> and that is not working... the db handle is getting messed up. Any >> ideas from this little experiment, anyone? >> >> >> On Mar 6, 2006, at 9:30 PM, Ron Savage wrote: >> >>> On Mon, 6 Mar 2006 21:18:09 -0600, Puneet Kishor wrote: >>> >>> Hi Puneet >>> >>>> 34= sub store { >>>> 35= my $self = shift; >>>> 36= my ($sid, $datastr) = @_; >>>> 37= return $self->set_error("store(): usage error") unless $sid >>>> && $datastr; >>>> 38= >>>> 39= my $dbh = $self->{Handle}; 40= >>>> 41= my $sth = $dbh->prepare("SELECT id FROM " . $self- >>>>> table_name . " WHERE id=?"); >>> >>> At this point I would write the value returned by $self -> >>> table_name() to the web server's log, or to a disk file. That will >>> tell you /exactly/ what the program thinks the table's name is. >>> >>>> 42= unless ( defined $sth ) { >>>> 43= return $self->set_error( "store(): \$sth->prepare >>>> failed with message " . $dbh->errstr ); >>>> 44= } . -- Puneet Kishor |