DBIx-Wrap

 view release on metacpan or  search on metacpan

Wrap.pm  view on Meta::CPAN

    || return undef;

  my $sth = $self->{_dbh}->prepare ($sql);
  $sth->execute
    || return $self->error ("Could not execute '$sql': "
                            . $self->{_dbh}->errstr);
  $self->{_error} = undef;
  
  my $iterator = DBIx::Wrap::Iterator->new ($sth);

  return $iterator;
}

=pod

=head2 insert

  $db->insert (Table    => 'passwd',
               Values   => {username	=> $username,
                            uid		=> $uid,
                            gcos	=> $gcos,
                            ...});

This method inserts a new entry into a database table.  See _prepare_sql
for the named parameters used.

=cut

sub insert {
  my $self = shift;
  my %params = @_;

  my $sql = $self->_prepare_sql ('insert', \%params)
    || return undef;

  my $sth = $self->{_dbh}->prepare ($sql);
  $sth->execute
    || return $self->error ("Could not execute '$sql': "
                            . $self->{_dbh}->errstr);
  $self->{_error} = undef;

  return 1;
}

=pod

=head2 update

  $db->update (Table    => 'passwd',
               Values   => {username    => $new_username,
                            pwd         => 'x',
                            uid         => $uid,
                            ...},
               Where    => "username='$old_username'");

This method updates an existing entry in a database table.  See
_prepare_sql for the named parameters used.

=cut

sub update {
  my $self = shift;
  my %params = @_;

  my $sql = $self->_prepare_sql ('update', \%params)
    || return undef;

  my $sth = $self->{_dbh}->prepare ($sql);
  $sth->execute
    || return $self->error ("Could not execute '$sql': "
                            . $self->{_dbh}->errstr);
  $self->{_error} = undef;

  return 1;
}

=pod

=head2 delete

  $db->delete (Table    => 'users',
               Where    => "username='jowaxman'");

This method deletes an existing entry from a database table.  See
_prepare_sql for the named parameters used.

=cut

sub delete {
  my $self = shift;
  my %params = @_;

  my $sql = $self->_prepare_sql ('delete', \%params)
    || return undef;

  my $sth = $self->{_dbh}->prepare ($sql);
  $sth->execute
    || return $self->error ("Could not execute '$sql': "
                            . $self->{_dbh}->errstr);
  $self->{_error} = undef;

  return 1;
}

=pod

=head2 show_tables

  my @tables = $db->show_tables ();

This method returns an array containg the table names.

=cut

sub show_tables {
  my $self = shift;

  my $sth = $self->{_dbh}->prepare ('show tables');
  $sth->execute
    || return $self->error ("Could not execute 'SHOW TABLES': "
                            . $self->{_dbh}->errstr);



( run in 1.227 second using v1.01-cache-2.11-cpan-99c4e6809bf )