G::DB Handler
Package variablesGeneral documentationMethods
Package variables
Privates (from "my" definitions)
$primarykey;
$dbh;
$table = "scratch"
Synopsis
No synopsis!
Description
No description!
Methods
columns
No description
Code
dbi
No description
Code
rows
No description
Code
search
No description
Code
set_dbi
No description
Code
set_primarykey
No description
Code
set_table
No description
Code
tables
No description
Code
Methods description
None available.
Methods code
columnsdescriptionprevnextTop
sub columns {
    die "Can't locate object method\" columns\"" unless($dbh);

    my $self = shift;

    my $sql = ("SELECT * FROM $table LIMIT 1");
    my $sth = $dbh->prepare($sql) || die $dbh->errstr;
    $sth->execute || die $sth->errstr;
    my $ref = $sth->fetchrow_hashref();

    return keys %$ref;
}
dbidescriptionprevnextTop
sub dbi {
    die "Can't locate object method\" dbi\"" unless($dbh);

    return $dbh;
}
rowsdescriptionprevnextTop
sub rows {
    die "Can't locate object method\" rows\"" unless($dbh);

    my $self = shift;;

    return keys %$self;
}
searchdescriptionprevnextTop
sub search {
    my $this = shift;

    my @args = @_;
    my $i = 0;
    my $where;

    while(defined $args[$i]){
	if(length($where)){
	    $where .= ' AND ';
	}else{
	    $where = ' WHERE ';
	}

        if (substr($args[$i], 0, 1) eq '-' && substr($args[$i], 1, 1) !~ /[0-9]/){
	    $where .= substr($args[$i],1) . ' = "' . $args[$i + 1] . '"';
            $i += 2;
        }else{
	    $where .= $args[$i];
            $i ++;
        }
    }

    print "select $primarykey from $table $where";
    my $ids = $dbh->selectcol_arrayref("select $primarykey from $table $where");

    return @$ids;
}
set_dbidescriptionprevnextTop
sub set_dbi {
    my $self = shift;
    $dbh = shift;
}
set_primarykeydescriptionprevnextTop
sub set_primarykey {
    my $self = shift;
    $primarykey = shift;
}
set_tabledescriptionprevnextTop
sub set_table {
    my $self = shift;
    $table = shift;
}
tablesdescriptionprevnextTop
sub tables {
    die "Can't locate object method\" tables\"" unless($dbh);

    my $self = shift;
    my %tables;

    foreach my $table ($dbh->tables(undef, 'public', undef, undef, {noprefix => 1})){
	$table =~ s/^\"(.*)\"$/$1/g;
	$tables{$table} ++;
    }

    return keys %tables;
}
General documentation
No general documentation available.