Changeset 6
- Timestamp:
- 05/03/06 23:59:06 (4 years ago)
- Location:
- trunk/lib/Data
- Files:
-
- 1 added
- 4 modified
-
ObjectDriver.pm (modified) (1 diff)
-
ObjectDriver/BaseObject.pm (modified) (1 diff)
-
ObjectDriver/Driver/DBI.pm (modified) (2 diffs)
-
ObjectDriver/Driver/DBI/Pg.pm (added)
-
ObjectDriver/Driver/DBI/mysql.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Data/ObjectDriver.pm
r5 r6 10 10 ## refactoring the DBI.pm code 11 11 ## - ability to define column => database for each value 12 ## - plugin interface for doing things like audit, filters 12 ## - plugin interface for doing things like audit, filters, column_defs 13 13 ## test suite 14 14 ## dbh needs to stay around at least as long as sth in iterator -
trunk/lib/Data/ObjectDriver/BaseObject.pm
r4 r6 83 83 84 84 sub column_names { 85 my $obj = shift; 86 my $props = $obj->properties; 87 my @cols = @{ $props->{columns} }; 88 push @cols, qw( created_on modified_on ) 89 if $props->{audit}; 90 \@cols; 85 ## Reference to a copy. 86 [ @{ shift->properties->{columns} } ] 91 87 } 92 88 -
trunk/lib/Data/ObjectDriver/Driver/DBI.pm
r5 r6 22 22 ## Rebless the driver into the DSN-specific subclass (e.g. "mysql"). 23 23 my($type) = lc($driver->dsn) =~ /^dbi:(\w*)/; 24 my $class = __PACKAGE__. '::' . $type;24 my $class = ref($driver) . '::' . $type; 25 25 eval "use $class"; 26 26 die $@ if $@; … … 45 45 # Override in DB Driver to pass correct attributes to bind_param call 46 46 sub bind_param_attributes { return undef } 47 48 sub init_db { 49 my $driver = shift; 50 my $dbh; 51 eval { 52 local $SIG{ALRM} = sub { die "alarm\n" }; 53 $dbh = DBI->connect($driver->dsn, $driver->username, $driver->password, 54 { RaiseError => 1, PrintError => 0, AutoCommit => 1 }) 55 or Carp::croak("Connection error: " . $DBI::errstr); 56 alarm 0; 57 }; 58 if ($@) { 59 Carp::croak(@$ eq "alarm\n" ? "Connection timeout" : $@); 60 } 61 $dbh; 62 } 47 63 48 64 sub rw_handle { -
trunk/lib/Data/ObjectDriver/Driver/DBI/mysql.pm
r4 r6 9 9 sub fetch_id { $_[1]->{mysql_insertid} || $_[1]->{insertid} } 10 10 11 sub init_db {12 my $driver = shift;13 my $dbh;14 eval {15 local $SIG{ALRM} = sub { die "alarm\n" };16 $dbh = DBI->connect($driver->dsn, $driver->username, $driver->password,17 { RaiseError => 1, PrintError => 0, AutoCommit => 1 })18 or Carp::croak("Connection error: " . $DBI::errstr);19 alarm 0;20 };21 if ($@) {22 Carp::croak(@$ eq "alarm\n" ? "Connection timeout" : $@);23 }24 $dbh;25 }26 27 11 sub commit { 1 } 28 12 sub rollback { 1 }
