| 1 | package MYDan::Subscribe::DBI::DB; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | use MYDan::Subscribe::DBI::DB; | ||
| 8 | |||
| 9 | my $db = MYDan::Subscribe::DBI::DB->new( '/database/file' ); | ||
| 10 | |||
| 11 | $db->select( 'node', name => [ 1, 'foo' ] ); | ||
| 12 | |||
| 13 | =cut | ||
| 14 | use strict; | ||
| 15 | use warnings; | ||
| 16 | |||
| 17 | =head1 METHODS | ||
| 18 | |||
| 19 | See MYDan::Util::SQLiteDB. | ||
| 20 | |||
| 21 | =cut | ||
| 22 | use base qw( MYDan::Util::SQLiteDB ); | ||
| 23 | |||
| 24 | =head1 DATABASE | ||
| 25 | |||
| 26 | A SQLITE db has a I<node> table of I<four> columns: | ||
| 27 | |||
| 28 | name : cluster name | ||
| 29 | attr : table name | ||
| 30 | user : node name | ||
| 31 | level : node name | ||
| 32 | |||
| 33 | =cut | ||
| 34 | our $TABLE = 'subscribe'; | ||
| 35 | |||
| 36 | sub define | ||
| 37 | { | ||
| 38 | name => 'TEXT NOT NULL', | ||
| 39 | attr => 'TEXT NOT NULL', | ||
| 40 | user => 'TEXT NOT NULL', | ||
| 41 | level => 'TEXT NOT NULL', | ||
| 42 | }; | ||
| 43 | |||
| 44 | |||
| 45 | =head3 insert( @record ) | ||
| 46 | |||
| 47 | Insert @record into $table. | ||
| 48 | |||
| 49 | =cut | ||
| 50 | sub insert | ||
| 51 | { | ||
| 52 | my $self = shift; | ||
| 53 | $self->SUPER::insert( $TABLE, @_ ); | ||
| 54 | } | ||
| 55 | |||
| 56 | =head3 select( $column, %query ) | ||
| 57 | |||
| 58 | Select $column from $table. | ||
| 59 | |||
| 60 | =cut | ||
| 61 | sub select | ||
| 62 | { | ||
| 63 | my $self = shift; | ||
| 64 | $self->SUPER::select( $TABLE, @_ ); | ||
| 65 | } | ||
| 66 | |||
| 67 | =head3 delete( %query ) | ||
| 68 | |||
| 69 | Delete records from $table. | ||
| 70 | |||
| 71 | =cut | ||
| 72 | sub delete | ||
| 73 | { | ||
| 74 | my $self = shift; | ||
| 75 | $self->SUPER::delete( $TABLE, @_ ); | ||
| 76 | } | ||
| 77 | |||
| 78 | 1; |