NAME
FWS::V2::Database - Framework Sites version 2 common database methods
VERSION
Version 0.001
SYNOPSIS
use FWS::V2;
#
# Create FWS with MySQL connectivity
#
my $fws = FWS::V2->new( DBName => "theDBName",
DBUser => "myUser",
DBPassword => "myPass");
#
# create FWS with SQLite connectivity
#
my $fws2 = FWS::V2->new( DBType => "SQLite",
DBName => "/home/user/your.db");
DESCRIPTION
Framework Sites version 2 common methods that connect, read, write, reorder or alter the database itself.
METHODS
connectDBH
Do the initial database connection via MySQL or SQLite. This method will return back the DBH it creates, but it is only here for completeness and would normally never be used. For FWS database routines this is not required as it will be implied when executing those methods..
$fws->connectDBH();
runSQL
Return an reference to an array that contains the results of the SQL ran.
#
# retrieve a reference to an array of data we asked for
#
my $dataArray = $fws->runSQL(SQL=>"select id,type from id_and_type_table"); # Any SQL statement or query
#
# loop though the array
#
while (@$dataArray) {
#
# collect the data each row at a time
#
my $id = shift(@$dataArray);
my $type = shift(@$dataArray);
#
# display or do something with the data
#
print "ID: ".$id." - ".$type."\n";
}
alterTable
It is not recommended you would use the alterTable method outside of its intended core database creation and maintenance routines but is here for completeness. Some of the internal table definitions alter data based on its context and will be unpredictable. For work with table structures not directly tied to the FWS 2 core schema, use FWS::Lite in a non web rendered script.
#
# retrieve a reference to an array of data we asked for
#
# Note: It is not recommended to change the data structure of
# FWS default tables
#
print $fws->alterTable( table =>"table_name", # case sensitive table name
field =>"field_name", # case sensitive field name
type =>"char(255)", # Any standard cross platform type
key =>"", # MUL, PRIMARY KEY, FULL TEXT
default =>""); # '0000-00-00', 1, 'this default value'...
tableFieldHash
Return a multi-dimensional hash of all the fields in a table with its properties. This usually isn't used by anything but internal table alteration methods, but it could be useful for someone making conditionals to determine the data structure before adding or changing data.
$tableFieldHashRef = $fws->tableFieldHash('the_table');
#
# the return dump will have the following structure
#
$hash->{field}{type}
$hash->{field}{key}
$hash->{field}{ord}
$hash->{field}{null}
$hash->{field}{default}
$hash->{field}{extra}
$hash->{field_2}{type}
$hash->{field_2}{key}
$hash->{field_2}{ord}
$hash->{field_2}{null}
$hash->{field_2}{default}
$hash->{field_2}{extra}
...
AUTHOR
Nate Lewis, <nlewis at gnetworks.com>
BUGS
Please report any bugs or feature requests to bug-fws-v2 at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FWS-V2. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc FWS::V2::Database
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2012 Nate Lewis.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.