« blib/lib/AutoSQL/DBSQL/ObjectAdaptor.pm
↑ Summary
blib/lib/AutoSQL/DBSQL/ObjectAdaptor/General.pm »
| 1 | package AutoSQL::DBSQL::ObjectAdaptor::Abstract; | ||
| 2 | use strict; | ||
| 3 | use AutoCode::Root; | ||
| 4 | our @ISA=qw(AutoCode::Root); | ||
| 5 | use AutoCode::AccessorMaker ('$'=>[qw(dbadaptor factory model)]); | ||
| 6 | |||
| 7 | sub _initialize { | ||
| 8 | my ($self, @args)=@_; | ||
| 9 | my ($dbadaptor, $dba, $type, $factory, $model)= | ||
| 10 | $self->_rearrange([qw(DBADAPTOR DBA TYPE FACTORY MODEL)], @args); | ||
| 11 | $dbadaptor ||= $dba; | ||
| 12 | $self->dbadaptor($dbadaptor); | ||
| 13 | $self->factory($factory); | ||
| 14 | $self->model($model); | ||
| 15 | } | ||
| 16 | |||
| 17 | sub db_handle { shift->dbadaptor->db_handle; } | ||
| 18 | sub prepare { shift->dbadaptor->prepare(@_); } | ||
| 19 | sub _primary_key_name { shift->model->primary_key_name; } | ||
| 20 | sub _table_name { shift->model->table_name; } | ||
| 21 | sub _slots { shift->model->get_scalar_slots; } | ||
| 22 | |||
| 23 | sub _slot_table_name { | ||
| 24 | my $table=shift->_table_name; | ||
| 25 | "$table\_" . shift; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub debug { | ||
| 29 | my ($self, $msg)=@_; | ||
| 30 | my $class=ref($self)||$self; | ||
| 31 | print STDERR "DEBUG IN $class\n$msg\n"; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; | ||
| 35 |