PET::Util::MySQL

PET::Util::MySQL

This package handles MySQL.  Needs much work!  Method names are currently fucked up.

FIXME, getDBH and SQLConnect should be moved to PET::Util::_ConnectionHandler ! FIXME, we should probably have a PET::Util::_SQL, too...  (Note: underscores mean that they are not really Util::* packages...)

Summary
PET::Util::MySQLThis package handles MySQL.
Variables
$IFLOG
$CONFIG
Functions
NAME
Variables
$CONNECTMETHOD
$defaulthandler
Functions
init ()
getDBH
SQLConnect
prepareSth(%p)Used by many SQL routines, this prepares a statement handle.
fetchSQL(%p)Issue an SQL query via (stored) SQL prepared statement, returns hashrefs of arrayref.
issueQuery
getSqlRow (%p)Gets a MySQL row.
getSqlArray
getRowById ($what, $id, $dbhname, %p)Get one hashref by a unique key usage: $UTIL->getRowById(‘users.id’ => 15, ‘main’);
searchSql
updateRowById
insertRow (%p)This is going to exchange insertRow later.
insertRow ($dbhname, $table, %values)Inserts a row into a MySQL table.
deleteRowById
fetchfromdbh
cleanup ()Clean up resources (only in some cases!)
DESTROY ()Clean up resources.

Variables

$IFLOG

our $IFLOG

$CONFIG

our $CONFIG

Functions

NAME

sub NAME

Variables

$CONNECTMETHOD

our $CONNECTMETHOD

$defaulthandler

my $defaulthandler

Functions

init ()

sub init
Default INIT methodinitializes some connections and stuff.

getDBH

sub getDBH

SQLConnect

sub SQLConnect

prepareSth(%p)

sub prepareSth

Used by many SQL routines, this prepares a statement handle.  Accepts: dbhname, query, prepared (default: 1), bindparams

Optional invocations

scalar, arrayref : a query on the default handler + query parameters scalar, scalar, arrayref : a query on the named handler (1st) + query + query params scalar : only one query is passed

fetchSQL(%p)

sub fetchSQL($%)

Issue an SQL query via (stored) SQL prepared statement, returns hashrefs of arrayref.  See also: <prepareSth>

issueQuery

sub issueQuery

getSqlRow (%p)

sub getSqlRow

Gets a MySQL row.  FIXME : probably the name should be “getSqlRowHashref”.  Directly passes parameters to prepareSth.  Returns a hashref.

getSqlArray

sub getSqlArray

getRowById ($what, $id, $dbhname, %p)

sub getRowById

Get one hashref by a unique key usage: $UTIL->getRowById(‘users.id’ => 15, ‘main’);

searchSql

sub searchSql

updateRowById

sub updateRowById

insertRow (%p)

sub insertRow2

This is going to exchange insertRow later.

insertRow ($dbhname, $table, %values)

sub insertRow

Inserts a row into a MySQL table.

$dbhname : database handler (TODO: this will change, this handling is illogical) $table : SQL table to insert into %values : key - value pairs (if value is a ref, then it is directly inserted, e.g.  \”NOW()” will result in “... field=NOW()...” instead of “...field=?...  [ “NOW()” ]...”

deleteRowById

sub deleteRowById

fetchfromdbh

sub fetchfromdbh

cleanup ()

sub cleanup

Clean up resources (only in some cases!)  Broken, FIXME

DESTROY ()

sub DESTROY

Clean up resources.  (FIXME)

Base class for all Util modules.
our $IFLOG
our $CONFIG
sub NAME
our $CONNECTMETHOD
my $defaulthandler
sub init
sub getDBH
sub SQLConnect
sub prepareSth
Used by many SQL routines, this prepares a statement handle.
sub fetchSQL($%)
Issue an SQL query via (stored) SQL prepared statement, returns hashrefs of arrayref.
sub issueQuery
sub getSqlRow
Gets a MySQL row.
sub getSqlArray
sub getRowById
Get one hashref by a unique key usage: $UTIL->getRowById(‘users.id’ => 15, ‘main’);
sub searchSql
sub updateRowById
sub insertRow2
This is going to exchange insertRow later.
sub insertRow
Inserts a row into a MySQL table.
sub deleteRowById
sub fetchfromdbh
sub cleanup
Clean up resources (only in some cases!)
sub DESTROY
Clean up resources.
Close