#===========================================================================
Copyright (C) 2008 by Nik Ogura. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Bug reports and comments to nik.ogura@gmail.com.
CGI::Lazy::DB
use CGI::Lazy; my $q = CGI::Lazy->new('/path/to/config/'); my $dbh = $q->db->dbh; #just get the dbh, and use it by hand $q->db->do('select...."); #use the db object's abstraction for queries with no return value my $value = $q->db->getarray($query, @binds); #get an array of arrays. my $value = $q->db->gethash($query, $key, @binds); #get a hash of hashes my $value = $q->db->gethashlist($query, @binds); #get ordered array of hashrefs. (This is probably the most useful)
CGI::Lazy database object. Contains convenience methods for common db operations and holds base database handle for object.
Returns config object.
Returns default database handle
Runs a given query with bind values specified. Does not expect a return value
raw sql to be run
array or literal values to be bound
Runs a given query with bind values specified. Returns first value found.
array ref to values to be bound or list of binds. If first element is a reference, it will be assumed that that is an array ref and it is all of the binds
Runs a given query with bind values specified. Returns array of arrays from DBI::fetchall_arrayref
Runs a given query with bind values specified. Returns hashref from DBI::fetchall_hashref
field to use as key for main hash
array of values to be bound
Runs a given query with bind values specified. Returns array of hashrefs
array of values to be bound or list of binds. If first element is a reference, it will be assumed that that is an array ref and it is all of the binds
Constructor. Builds or inherits database handle and returns DB object.
Database handles may be handled in one of 3 ways:
1) built from username, password, and connect string specified in the config file
2) build in the cgi and explicitly passed to the Lazy object on object creation.
3) a known variable that is in scope in the cgi can be specified, in which case the program will look for this variable, and pick it up.
Note: with mod_perl option 3 is a little more hairy. You will need to specify the mod_perl request handler being used, e.g. ModPerl::Registry or ModPerl::PerlRun in the apache config.
Lazy Object
Returns CGI::Lazy object
Creates and returns a CGI::Lazy::DB::RecordSet object.
See CGI::Lazy::DB::RecordSet for more information.
hashref of RecordSet properties
Returns driver type from database handle object. Necessary for specifying different behaviors dependant on databse capabilities.
To install CGI::Lazy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Lazy
CPAN shell
perl -MCPAN -e shell install CGI::Lazy
For more information on module installation, please visit the detailed CPAN module installation guide.