NAME

Apache2::Controller::SQL::MySQL - useful database methods for MySQL

VERSION

Version 0.110.000 - BETA TESTING (ALPHA?)

SYNOPSIS

package UFP::SFC::Controller::Tools;
use base qw( 
    Apache2::Controller 
    Apache2::Controller::SQL::MySQL
);
# ...

DESCRIPTION

Provides some useful methods for interacting with a MySQL database.

METHODS

insert_hash

insert_hash( \%hashref )

Insert data into the database.

# http://sfc.ufp/tools/register_crew/enterprise?captain=kirk&sci=spock&med=mccoy
sub register_crew {
    my ($self, $ship) = @_; 
    my $crew = $self->param();
    $self->insert_hash({
        table    => "crew_$ship",
        data     => $crew,
    });
    $self->print("Warp factor 5, engage.\n");
    return Apache2::Const::HTTP_OK;
}

Requires $self->pnotes->{dbh} be connected. See Apache2::Controller::DBI::Connector.

Hashref argument supports these fields:

table

The SQL table to insert into.

data

The hash ref of field data to insert.

on_dup_sql

Optional string of SQL for after 'ON DUPLICATE KEY UPDATE'. Format it yourself.

on_dup_bind

Array ref of bind values for extra ? characters in on_dup_sql.

SEE ALSO

Apache2::Controller::DBI::Connector

Apache2::Controller

AUTHOR

Mark Hedges, hedges +(a t)- scriptdolphin.org

COPYRIGHT AND LICENSE

Copyright 2008 Mark Hedges. CPAN: markle

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