载] Class
::D
BI Technology Dealtimeauto Cs Album Logout Asp Deal Time Auto" href="http://technology.dealtimeauto.com/feed//cs/Album/logout.asp" />
载] Class
::D
BI Technology Dealtimeauto Cs Album Logout Asp Deal Time Auto
载] Class
::D
BI Technology Dealtimeauto Cs Album Logout Asp Deal Time Auto
(available from
vides a simple int
face to a phone
bill downloaded_from the BT Web site. So, armed with
details in a
database, and see how to extract useful information from them.
Data::BT::PhoneBill(可在CPAN下载)给我们一个从BT的网站下载电话帐单的方法。有了这个模块和一些最近的通话帐单条目,我们就可以用数据库来存储详细信息以备分析。
Class::DBI works on the basis that each table in your database has a corresponding class. Although each class could set up its own connection information, it's a better idea to encapsulate that connection in one class, and have all the others inherit from that. So, we set up our database, and create the base class for our application:
Class::DBI的基本概念是数据库中的每个表都有相应的类。尽管每个类都可以自己做连接(数据库)相关的事情,最好还是有个类来把这些事情封装起来。所以我们要建立数据库并为应用程序建立基类:
package My::PhoneBill::DBI;
use base 'Class::DBI';
__PACKAGE__->set_db('Main', 'dbi:mysql:phonebill', 'u/n', 'p/w');
1;
We simply inherit from Class::DBI and use the 'set_db' method to set up the connection information for our database. That's all we need in this class for now, so next we set up our table for storing the phone call information:
我们只是从Class::DBI继承并用'set_db'方法来建立数据库连接。目前这就是我们在这个类里面需要做的事情,下面我们开始建立用于存储通话信息的表:
CREATE TABLE call ( callid MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, number VARCHAR(20) NOT NULL, destination VARCHAR(255) NOT NULL, calldate DATE NOT NULL, calltime TIME NOT NULL, type VARCHAR(50) NOT NULL, duration SMALLINT UNSIGNED NOT NULL, cost FLOAT(8,1) );For this, we set up a corresponding class:
为这个我们要建立相应的类:
package My::PhoneBill::Call;
use base 'My::PhoneBill::DBI';
__PACKAGE__->table('call');
__PACKAGE__->columns(All => qw/callid number destination calldate calltime type duration cost/);
1;
We inherit our connection information from our base class, and then specify what table we're dealing with, and what its columns are. Now we have enough to populate the table.
我们从基类来继承连接信息,并声明我们要用的表和它包含的列。现在我们要开始填充表里面的数据了。
So, we create a simple, "populate_phone_bill" script:
我们建立了一个简单的名为"populate_phone_bill"的脚本:
#!/usr/bin/perl
use Data::BT::PhoneBill;
use My::PhoneBill::Call;
my $file = shift or die "Need a phone bill file";
my $bill = Data::BT::PhoneBill->new($file) or die "Can't parse bill";
while (my $call = $bill->next_call) {});
}
zTechnology Dealtimeauto Cs Album Logout Asp Deal Time Auto [
载] Class
::D
BI Technology Dealtimeauto Cs Album Logout Asp Deal Time Autoj w Deal x Deal n Time Time
uTechnology Dealtimeauto Cs Album Logout Asp Deal Time Auto [
载] Class
::D
BI Technology Dealtimeauto Cs Album Logout Asp Deal Time Autoy d Auto h Deal Auto