WWW::MLite::Store::DBI - Database independent interface for WWW::MLite on CTK::DBI based
Version 1.01
use WWW::MLite::Store::DBI; # MySQL connect my $mysql = new WWW::MLite::Store::DBI ( -mlite => $mlite, # OPTIONAL -dsn => 'DBI:mysql:database=TEST;host=192.168.1.1', -user => 'login', -pass => 'password', -connect_to => 5, -request_to => 60 -attr => { mysql_enable_utf8 => 1, RaiseError => 0, PrintError => 0, }, ); # See CTK::DBI # MySQL connect (old style, without DSN) my $mysql = new WWW::MLite::Store::DBI ( -mlite => $mlite, # OPTIONAL -driver => 'mysql', # Driver name. See DBI module # Available drivers: # CSV, DBM, ExampleP, File, Gofer, ODBC, Oracle, # Pg, Proxy, SQLite, Sponge, mysql -host => '192.168.1.1', -port => '3306', # default -database => 'TEST', -user => 'login', -pass => 'password', -attr => { mysql_enable_utf8 => 1, RaiseError => 0, PrintError => 0, }, ); my $dbh = $mysql->connect; my $pingstat = $mysql->ping if $mysql; $mysql->reconnect() unless $pingstat; # Table select (as array) my @result = $mysql->table($sql, @inargs); # Table select (as hash) my %result = $mysql->tableh($key, $sql, @inargs); # $key - primary index field name # Record (as array) my @result = $mysql->record($sql, @inargs); # Record (as hash) my %result = $mysql->recordh($sql, @inargs); # Fiels (as scalar) my $result = $mysql->field($sql, @inargs); # SQL/PL-SQL my $sth = $mysql->execute($sql, @inargs); ... $sth->finish;
Database independent interface for WWW::MLite on CTK::DBI based.
Set $WWW::MLite::Store::DBI::DEBUG_FORCE = 1 for enable debugging in STDERR where object $mlite undefined
Coming soon
my $status = $mysql->ping();
Returns connection's life status
$mysql->reconnect unless $mysql->ping();
my $err = $mysql->err; my $errstr = $mysql->errstr; my $state = $mysql->state;
Methods returns DBI values: err, errstr and state.
See "METHODS_COMMON_TO_ALL_HANDLES" in DBI
use WWW::MLite::Store::DBI; # eval 'sub CTK::DBI::_error {1}'; # For supressing CTK::DBI errors my $mysql => new WWW::MLite::Store::DBI ( -mlite => $mlite, -dsn => 'DBI:mysql:database=NAME;host=HOST', -user => 'USER', -pass => 'PASSWORD', -attr => { mysql_enable_utf8 => 1, RaiseError => 0, PrintError => 0, HandleError => sub { $m->log_error(shift || '') }, }, ) ... my @data = $mysql->table('select * from table');
use WWW::MLite::Store::DBI; my $mysql => new WWW::MLite::Store::DBI ( -mlite => $mlite, # OPTIONAL -dsn => 'DBI:mysql:database=NAME;host=HOST', -user => 'USER', -pass => 'PASSWORD', -attr => { mysql_enable_utf8 => 1, RaiseError => 0, PrintError => 0, HandleError => sub { $m->log_error(shift || '') }, }, ) ... $mysql->reconnect unless $mysql->ping; ... my @data = $mysql->table('select * from table');
# Oracle connect my $oracle = new WWW::MLite::Store::DBI ( -mlite => $mlite, # OPTIONAL -driver => 'Oracle', -host => '192.168.1.1', -database => 'TEST', -user => 'login', -pass => 'password', -attr => { RaiseError => 0, PrintError => 0, }, ) ... my $value = mysql->field('select sysdate from dual');
use WWW::MLite::Store::DBI; $WWW::MLite::Store::DBI::DEBUG_FORCE = 1; my $dbi = new WWW::MLite::Store::DBI ( -driver => 'mysql', -name => 'mylocaldb', -user => 'user', -password => 'password' ); ... my @table = $dbi->table("select * from tablename where date = ?", "01.01.2000");
use WWW::MLite::Store::DBI; $WWW::MLite::Store::DBI::DEBUG_FORCE = 1; my $o = new WWW::MLite::Store::DBI( -driver => 'Sponge', -attr => { RaiseError => 1 }, ); my $dbh = $o->connect(); my $sth = $dbh->prepare("select * from table", { rows => [ [qw/foo bar baz/], [qw/qux quux corge/], [qw/grault garply waldo/], ], NAME => [qw/h1 h2 h3/], }); $sth->execute(); my $result = $sth->fetchall_arrayref; $sth->finish; print Dumper($result);
See CHANGES file
CHANGES
CTK::DBI, DBI
Serz Minus (Lepenkov Sergey) http://www.serzik.com <minus@mail333.com>
Copyright (C) 1998-2014 D&D Corporation. All Rights Reserved
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See LICENSE file
LICENSE
To install WWW::MLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::MLite
CPAN shell
perl -MCPAN -e shell install WWW::MLite
For more information on module installation, please visit the detailed CPAN module installation guide.