Manuel Batista > dbi_simple > DBI::Simple

Download:
dbi_simple/dbi_simple.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.03   Source  

NAME ^

DBI::Simple - Perl extension for DBI

SYNOPSIS ^

  use DBI::Simple;

ABSTRACT ^

  DBI::Simple - Perl extension for DBI

DESCRIPTION ^

DBI::Simple is a perl5 module to simplify the use of DBI.

USAGE ^

Create a new dbh connection.

use DBI::Simple; my $dbh = new DBI::Simple( DB => $database, HOST => $host, UID => $user, PWD => $passwd );

METHODS ^

$dbh->set(%options)

Set the dbh connection if not done in constructor.

$dbh->host($host)

Get or set the host for the dbh connection.

$dbh->uid($uid)

Get or set the uid for the dbh connection.

$dbh->pwd($pwd)

Get or set the password for the dbh connection.

$dbh->db($db)

Get or set the database for the dbh connection.

$dbh->dbh()

Get the dbh for the dbhh connection.

$dbh->connect()

Reconnect to databse.

$dbh->do($sql_statment)

Execute any sql command.

$dbh->process($file)

Process contents of a file. SQL statements are split by semicolons.

$dbh->tables()

Get the list of tables in the current database. return type array reference.

$dbh->columns($table)

Get the columns in $table. return type array reference.

$dbh->selectcol($select)

Get the first column from $select. return type array reference.

$dbh->query($select)

Get query into a list of array references. return type array reference.

$dbh->query_columns($select)

converts $dbh->query (rows) into columns. this is usefull for GD::Graphs

$dbh->query_hash($select)

Get query into a hash with list of values.

USE: ## RETURNS A HASH WITH THE COLUMN AS VALUE my $query_hash = $dbh->query_hash('select * from test'); foreach my $column (keys %$query_hash){ my @column_data = $query_hash->{$column}; ## DO SOMETHING WITH THE DATA IN THE COLUMN print "$column : @column_data\n"; } return type hash reference.

$dbh->list_hash($select)

Get query into list of hashes.

USE: ## RETURNS A LIST OF HASHES my $list_hash = $dbh->list_hash('select * from test'); foreach my $hash (@$list_hash){ ## DO SOMETHING WITH THE HASH foreach my $key (keys %$hash){ ## KEY : VALUE print "$key : $hash->{$key} \n"; } } return type array reference.

$dbh->insert($table, $columns, $values)

Takes list of coluumns (array reference) and list of values (array reference) and insertes it into the given $table.

USE: $dbh->insert('test', ['col1', 'col2'], ['val1', 'val2']);

$dbh->insert_hash($table, $hash)

Inserts the given hash reference into the given $table.

USE: $dbh->insert_hash('test', {col1 => 'val1', col2 => 'val2'});

$dbh->update($table, $set, $where)

parameters: string, hash_ref, hash_ref Updates the given data in $table.

USE: $dbh->update( 'test', # TABLE { col1 => 'new_val1', # SET col TO new_val1 .. col2 => 'new_val2'}, { colx => 'val', # WHERE colx EQUALS val .. coly => 'val'} # THIS IS OPTIONAL );

SEE ALSO ^

perldoc DBI::Simple perldoc DBI

AUTHOR ^

Manny Batista, <mbatista@ccs.neu.edu<gt>

COPYRIGHT AND LICENSE ^

Copyright 2007 by Manny Batista

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: