📄 database.pm
字号:
package astercon::database;#--------------------------------------------------------------## Astercon -- An open source softswitch and ippbx system.## Copyright (C) 2006 - 2008, Sun bing.## Sun bing <hoowa.sun@gmail.com>## See http://astercon.0420.com for more information about# the Astercon project.## license# The astercon project is licensed under the GNU 2.0 GPL. # astercon carries no restrictions on re-branding and # people are free to commercially re-distribute it.## FAQ# Please do not directly contact any of the maintainers of# this project for assistance;# the project provides a web site, bugs tracker,really chat.##--------------------------------------------------------------#use Carp qw(carp croak);use DBI;use strict;use vars qw($VERSION @ISA);use astercon::database::admin;use astercon::database::billing;use astercon::database::user;$VERSION='0.1';BEGIN { @ISA = qw(DBI astercon::database::admin astercon::database::billing astercon::database::user);}sub DESTROY{my $self = shift; if ($self->{dbh} && $self->{dbh}->ping) { $self->disconn; }}sub new {my $class = shift;my $self = {};my %args = @_; # database args $self->{dbuser} = $args{dbuser}; $self->{dbpasswd} = $args{dbpasswd}; $self->{dbname} = $args{dbname}; $self->{dbhost} = $args{dbhost}; if (!$args{dbport}) { $self->{dbport} = 3306; } else { $self->{dbport} = $args{dbport}; } if (!exists $args{dbsock}) { die "Can't Find dbsock"; exit; } $self->{dbsock} = $args{dbsock}; # dbi object $self->{dbh} = undef; bless $self, $class; $self->conn() if ($args{conn});return $self;}sub conn{my $self = shift;my $dsn = "DBI:mysql:database=".$self->{dbname}.";host=".$self->{dbhost}.";port=".$self->{dbport}.";mysql_socket=".$self->{dbsock}; $self->{dbh} = DBI->connect($dsn, $self->{dbuser}, $self->{dbpasswd}) or croak($DBI::errstr);return;}sub disconn{my $self = shift; $self->{dbh}->disconnect;return;}1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -