Changeset 29 for LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
- Timestamp:
- 04/23/09 02:54:47 (15 years ago)
- Location:
- LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r21 r29 1 package LATMOS::Accounts::Bases::S QL::object;1 package LATMOS::Accounts::Bases::Sql::objects; 2 2 3 3 use 5.010000; … … 37 37 =cut 38 38 39 sub list { 40 my ($class, $base) = @_; 41 42 my $sth = $base->db->prepare_cached( 43 sprintf( 44 q{select %s as k from %s order by %s}, 45 $base->db->quote_identifier($class->key_field), 46 $base->db->quote_identifier($class->object_table), 47 $base->db->quote_identifier($class->key_field), 48 ) 49 ); 50 $sth->execute; 51 my @keys; 52 while(my $res = $sth->fetchrow_hashref) { 53 push(@keys, $res->{k}); 54 } 55 @keys 56 } 57 39 58 sub new { 40 59 my ($class, $base, $id) = @_; … … 51 70 $self->db->quote_identifier($table); 52 71 } 72 sub quote_key_field { 73 my ($self) = @_; 74 my $key_field = $self->key_field or return; 75 $self->db->quote_identifier($key_field); 76 } 53 77 54 78 sub get_field { … … 56 80 my $sth = $self->db->prepare_cached( 57 81 sprintf( 58 q{select %s from %s where login= ?},82 q{select %s from %s where %s = ?}, 59 83 $self->db->quote_identifier($field), 60 84 $self->quote_object_table, 85 $self->quote_key_field, 61 86 ) 62 87 ); … … 79 104 sprintf( 80 105 q{update %s set %s where login = ?}, 81 $self->quote_object_table ),106 $self->quote_object_table, 82 107 join(', ', @fields), 83 108 )
Note: See TracChangeset
for help on using the changeset viewer.