package pca;

;#--- pod Start -----------------------------------------------------------#
=pod

=head1 NAME

pca.pm - 共通サブルーチン群

=head1 概要

DBアクセス用サブルーチン、文字変換ルーチン
オーク共通処理用サブルーチン、その他細かいルーチンの集まり

=head1 サブルーチン

=cut
;#--- pod Start -----------------------------------------------------------#

;; our $VERSION = '0.00';
@ISA = qw(DBI);
use strict;
use DBI;
use Jcode;

#------------------------------------------------------------------
sub new {
#------------------------------------------------------------------

=head2 ＤＢオープン [new]

webdb-param.plの内容でＤＢをオープンして
データベースハンドルを返す

=cut
	my $class = shift;
        my $self = {};
	$self->{pca} = shift;
#	my $server = $self->{pca}->{-server} || 'SS7:1254';
#	my $server = $self->{pca}->{-server} || 'sne00_jnet:1080';	#TEST機
	my $server = $self->{pca}->{-server} || 'SS7';	#TEST機
	my $user = $self->{pca}->{-user}||'sa';
	my $passwd = $self->{pca}->{-passwd}||'SNE00';
	my $database = $self->{pca}->{-database}||'OUTERSNE';
        eval{
                $self->{'dbh'} = DBI->connect("dbi:Sybase:$server"
				,$user,$passwd)
                                        or die $DBI::errstr;
        };
        bless $self,$class;
	$self->{dbh}->do("use $database");
        return  $self ;
}

sub euc2sj{
	my $s = shift;
	my $text = shift;
	return jcode($text,"euc")->sjis;
}
sub sj2euc{
	my $s = shift;
	my $text = shift;
	return jcode($text,"sjis")->euc;
}
sub urlencode{
	my $s = shift;
	my $text = shift;
	$text =~ s/([^(\w|=|&)])/'%' . unpack('H2',$1)/eg;
	return $text;
}
sub trim{
	my $s = shift;
	my $text = shift;
	$text =~ s/\s+$//;
	return $text;
}
1;
__END__

=head1 AUTHOR INFORMATION

 ;######################################################################
 ;#
 ;# pca.pm: pca ACCESS Sub Routine.
 ;#
 ;# Copyright (c) 2005 Masashi Hori <hori@japannet.co.jp>
 ;# JapanNet. All Rights Reserved.
 ;#
 ;#
 ;######################################################################

=cut

