Hello,
I thought I understood how to organize several write operations within a
transaction but it still doesn't work the way I do it.
Here is what I have so far:
In my base class:
sub init_db {
my $self = shift;
my $db;
if (not $self->my_db) {
$self->my_db( MyApp::DB->new() )
John Siracusa writes:
> On 8/7/07 5:12 PM, George Hartzell wrote:
> > If I change Rose::DB::SQLite::validate_datetime_keyword so that it'll
> > accept 'current_timestamp'
>
> Yeah, I should do that...
>
> > then the value gets inserted literally into the table.
>
> it probably also need
On 8/14/07, George Hartzell <[EMAIL PROTECTED]> wrote:
> The default value of "now" does work when used in the RDBO perl
> module. The problem is that since I'm using RDBO::Loader, the only
> way to get that value in there is to use it in the SQL, where it
> doesn't do what is intended.
Remember
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> my $db = MyApp::DB->new;
> $self->my_db($db); # a new db for a new transaction
> $db->begin_work; # Start transaction
>
> ... create two objects and save them ...
>
> die "Does it roll back?";
> $db->commit;
I don't see any rollback there.
On 14.08.2007 16:54 Perrin Harkins wrote:
>> $db->begin_work; # Start transaction
>> die "Does it roll back?";
>> $db->commit;
>
> I don't see any rollback there. It's a common practice to put an
Well, my understandig was that if perl dies within a transaction it (or
DBI) would do a rollback,
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Well, my understandig was that if perl dies within a transaction it (or
> DBI) would do a rollback, from your answer I guess this is not the case.
No. Your database will do it if you cut the connection and there is
uncommitted work, but pe
On 14.08.2007 17:50 Perrin Harkins wrote:
>> do you have any pointer on how this is done (correctly)?
>
>$r->push_handlers(PerlCleanupHandler => sub {
>MyApp::DB->rollback();
>});
Thanks! That's exactly what I needed. I found already that there is a
PerlCleanupHandler directive i
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Only question: Is it really possible to call rollback as a class method
> or do I have to call it on the specific object that started the transaction?
You have to call it on the database handle that started the
transaction. If all of your
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> And to the second alternative, how do I have to setup RDBO with mod_perl
> to share a db (and dbh with it) for everything within one
> process/request but not across multiple processes?
The simplest way to do this is to leave everything as
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> The simplest way to do this is to leave everything as per the
> defaults, and just use Apache::DBI.
Note that Apache::DBI also does the automatic rollback for you, but
only if you have AutoCommit off when you connect. If you connect with
Auto
On 8/14/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> Note that Apache::DBI also does the automatic rollback for you, but
> only if you have AutoCommit off when you connect. If you connect with
> AutoCommit on, you have to handle the rollback yourself.
Doesn't Apache::DBI just care that $dbh->{
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> Doesn't Apache::DBI just care that $dbh->{AutoCommit} is false at the
> time it checks in the cleanup handler?
Look further up in the code. It never pushes the handler unless
AutoCommit is off. Probably a mistake in my opinion. If others
ag
On 8/14/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> > Doesn't Apache::DBI just care that $dbh->{AutoCommit} is false at the
> > time it checks in the cleanup handler?
>
> Look further up in the code. It never pushes the handler unless
> Au
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> I looked for that and didn't see it, and still don't see it.
Sorry, this was actually changed already. I was looking at an older release.
- Perrin
-
This SF.net email i
On Tue, Aug 14, 2007 at 11:57:27AM +0200, Michael Lackhoff wrote:
> my $db = MyApp::DB->new;
> $self->my_db($db); # a new db for a new transaction
> $db->begin_work; # Start transaction
>
> ... create two objects and save them ...
>
> die "Does it roll back?";
> $db->commit;
>
> But when I run
On 14.08.2007 18:54 Perrin Harkins wrote:
> On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
>> The simplest way to do this is to leave everything as per the
>> defaults, and just use Apache::DBI.
>
> Note that Apache::DBI also does the automatic rollback for you, but
> only if you have AutoC
On 14.08.2007 20:20 Bill Moseley wrote:
> On Tue, Aug 14, 2007 at 11:57:27AM +0200, Michael Lackhoff wrote:
>> my $db = MyApp::DB->new;
>> $self->my_db($db); # a new db for a new transaction
>> $db->begin_work; # Start transaction
>>
>> ... create two objects and save them ...
>>
>> die "Does i
On 8/14/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> > I looked for that and didn't see it, and still don't see it.
>
> Sorry, this was actually changed already. I was looking at an older release.
Phew. Because I have stuff going to produ
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> $db->begin_work;
> my $obj = Products->new(db => $db);
> ...
> $obj->save;
> some_helper_that_uses_db(); # rollback here
> my $obj2 = Customers->new(db => $db);
> ...
> $obj2->save;
> $db->commit;
>
> When I ran this code $obj2 was saved but
On Tue, Aug 14, 2007 at 08:28:40PM +0200, Michael Lackhoff wrote:
> > Have you also looked at Roes::DB's do_transaction() ?
>
> I know that this is another possible variant but because there is so
> much code I didn't want to squeeze it into a single call. It would do
> after some reorganization b
On 14.08.2007 20:34 John Siracusa wrote:
> On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
>> $db->begin_work;
>> my $obj = Products->new(db => $db);
>> ...
>> $obj->save;
>> some_helper_that_uses_db(); # rollback here
>> my $obj2 = Customers->new(db => $db);
>> ...
>> $obj2->save;
>> $db-
On 14.08.2007 20:37 Bill Moseley wrote:
> On Tue, Aug 14, 2007 at 08:28:40PM +0200, Michael Lackhoff wrote:
>> > Have you also looked at Roes::DB's do_transaction() ?
>>
>> I know that this is another possible variant but because there is so
>> much code I didn't want to squeeze it into a single
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> On 14.08.2007 20:34 John Siracusa wrote:
> > On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> >> $db->begin_work;
> >> my $obj = Products->new(db => $db);
> >> ...
> >> $obj->save;
> >> some_helper_that_uses_db(); # rollback here
>
23 matches
Mail list logo