MPMinus
view release on metacpan or search on metacpan
MULTISTORE CONFIGURATION
The following construction is used to configure the Multistore
mechanism:
<store foo>
dsn DBI:mysql:database=TEST;host=192.168.1.1
user login
pass password
<Attr>
mysql_enable_utf8 1
RaiseError 0
PrintError 0
</Attr>
</store>
<store bar>
dsn DBI:Oracle:FOOSID
user login
pass password
<Attr>
RaiseError 0
lib/MPMinus.pm view on Meta::CPAN
Setting node by name
For example (in handler of MPM::foo::Handlers module):
# Set r as Apache2::RequestRec object
$m->set( r => $r );
# Set mysql as MPMinus::Store::MySQL object
$m->set( mysql => new MPMinus::Store::MySQL(
-m => $m,
-attributes => {mysql_enable_utf8 => 1
})
) unless $m->mysql;
# Set disp as MPMinus::Dispatcher object
$m->set(
disp => new MPMinus::Dispatcher($m->conf('project'),$m->namespace)
) unless $m->disp;
# Initialising dispatcher record
my $record = $m->disp->get(-uri=>$m->conf('request_uri'));
lib/MPMinus/Manual.pod view on Meta::CPAN
=head3 MULTISTORE CONFIGURATION
The following construction is used to configure the Multistore mechanism:
<store foo>
dsn DBI:mysql:database=TEST;host=192.168.1.1
user login
pass password
<Attr>
mysql_enable_utf8 1
RaiseError 0
PrintError 0
</Attr>
</store>
<store bar>
dsn DBI:Oracle:FOOSID
user login
pass password
<Attr>
RaiseError 0
lib/MPMinus/Store/DBI.pm view on Meta::CPAN
use MPMinus::Store::DBI;
# MySQL connect
my $mysql = new MPMinus::Store::DBI (
-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 MPMinus::Store::DBI (
-m => $m, # 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;
lib/MPMinus/Store/DBI.pm view on Meta::CPAN
-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,
},
);
Returns MPMinus::Store::DBI object. See also L<CTK::DBI>
=item B<ping>
my $status = $mysql->ping();
lib/MPMinus/Store/DBI.pm view on Meta::CPAN
...
# MySQL connect
$m->set_node(
mysql => new MPMinus::Store::DBI (
-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 || '') },
},
)
) unless $m->mysql;
...
}
lib/MPMinus/Store/DBI.pm view on Meta::CPAN
if ($m->mysql) {
$m->mysql->reconnect unless $m->mysql->ping;
} else {
# eval 'sub CTK::DBI::_error {1}'; # For supressing CTK::DBI errors
$m->set_node(
mysql => new MPMinus::Store::DBI (
-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 || '') },
},
)
);
}
...
lib/MPMinus/Store/MultiStore.pm view on Meta::CPAN
use MPMinus::Store::MultiStore;
# Multistoring
my $mso = new MPMinus::Store::MultiStore (
-mso => {
foo => {
-dsn => 'DBI:mysql:database=TEST;host=192.168.1.1',
-user => 'login',
-pass => 'password',
-attr => {
mysql_enable_utf8 => 1,
RaiseError => 0,
PrintError => 0,
},
},
bar => {
-dsn => 'DBI:Oracle:SID',
-user => 'login',
-pass => 'password',
-attr => {
RaiseError => 0,
lib/MPMinus/Store/MultiStore.pm view on Meta::CPAN
return Apache2::Const::OK;
}
In conf/mso.conf file:
<store foo>
dsn DBI:mysql:database=TEST;host=192.168.1.1
user login
pass password
<Attr>
mysql_enable_utf8 1
RaiseError 0
PrintError 0
</Attr>
</store>
<store bar>
dsn DBI:Oracle:FOOSID
user login
pass password
connect_to 10
request_to 50
lib/MPMinus/Store/MySQL.pm view on Meta::CPAN
use MPMinus::Store::MySQL;
# MySQL connect
my $mysql = new MPMinus::Store::MySQL (
-host => '192.168.1.1',
-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;
# Table select (as array)
lib/MPMinus/Util.pm view on Meta::CPAN
Converting MSO configuration section to MultiStore -mso arguments
In conf/mso.conf:
<store foo>
dsn DBI:mysql:database=NAME;host=HOST
user login
pass password
<Attr>
mysql_enable_utf8 1
RaiseError 0
PrintError 0
</Attr>
</store>
<store bar>
dsn DBI:Oracle:SID
user login
pass password
<Attr>
( run in 0.294 second using v1.01-cache-2.11-cpan-00829025b61 )