MySQL-Admin
view release on metacpan or search on metacpan
lib/DBI/Library.pm view on Meta::CPAN
host => $m_sHost,
user => $m_sUser,
password => $m_sPassword,
}
);
=cut
sub new {
my ($class, @initializer) = @_;
my $self = {};
my $m_dbh;
bless $self, ref $class || $class || $m_sDefaultClass;
$m_dbh = $self->initDB(@initializer) if (@initializer);
return ($self, $m_dbh) if $m_dbh;
return $self;
}
=head2 initDB()
my $dbh = initDB(
{
name => 'LZE',
host => 'localhost',
user => 'root',
password =>'',
}
);
=cut
sub initDB {
my ($self, @p) = getSelf(@_);
my $hash = $p[0];
$m_sDatabase =
defined $hash->{name}
? $hash->{name}
: '%DATABASE%';
$m_sHost = defined $hash->{host} ? $hash->{host} : 'localhost';
$m_sUser = defined $hash->{user} ? $hash->{user} : 'root';
$m_sPass = defined $hash->{password} ? $hash->{password} : '';
my $install = defined $hash->{install} ? $hash->{install} : 0;
$m_sStyle = defined $hash->{style} ? $hash->{style} : 'mysql';
$m_dsn = "DBI:$driver:database=$m_sDatabase;host=$m_sHost";
$m_dbh = DBI::Library->connect(
$m_dsn, $m_sUser, $m_sPass,
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
#mysql_enable_utf8 => 1
}
)
or warn "$DBI::Library::errs";
$self->void("SET NAMES 'utf8_general_ci'");
if (!$install && $m_sDatabase eq '%DATABASE%') {
my @q = $self->fetch_array('select title from querys');
$m_hFunctions{$_} = $_ foreach (@q);
}
return $m_dbh;
}
=head2 Driver()
set or get the driver
Driver()
default: Mysql
=cut
sub Driver {
if ($_[0]) {
$driver = $_[0];
} else {
return $driver;
}
}
=head2 CurrentDb()
return the current used Database
=cut
sub CurrentDb {
return $m_sDatabase;
}
=head2 CurrentHost()
return the current Host
=cut
sub CurrentHost {
return $m_sHost;
}
=head2 CurrentUser()
gibt den aktuellen user zurueck
=cut
sub CurrentUser {
return $m_sUser;
}
=head2 CurrentPass()
( run in 2.209 seconds using v1.01-cache-2.11-cpan-56fb94df46f )