Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    EasyDBAccess 3.1.1

    Download button

    No screenshots available
    Downloads: 384  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.0/5)
    9 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    QIAN YU | More programs
    Perl Artistic License / FREE
    January 23rd, 2008, 12:27 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    EasyDBAccess description

    EasyDBAccess is a Perl database access interface.

    EasyDBAccess is a Perl database access interface.

    SYNOPSIS

    use EasyDBAccess;

    if(defined(&EasyDBAccess::foo)){
    print "lib is included";
    }else{
    print "lib is not included";
    }

    my $dba=EasyDBAccess->new({host=>'127.0.0.1',usr=>'root',pass=>'passwd',database=>'test_db'});
    my $dba=EasyDBAccess->new({socket=>'/tmp/mysql.sock',usr=>'root',pass=>'passwd',database=>'test_db'});
    my $dba=EasyDBAccess->new({host=>'127.0.0.1',usr=>'root',pass=>'passwd',database=>'test_db',encoding=>'gbk'});

    #disable die in next operation
    EasyDBAccess->once();
    my ($dba,$err_code)=EasyDBAccess->new({host=>'127.0.0.1',usr=>'root',pass=>'passwd',database=>'test_db'});
    if($err_code==3){
    print "Connect Error";
    }elsif($err_code==0){
    print "Connect Succ";
    }else{
    CORE::die 'BUG';
    }

    my $dba=EasyDBAccess->new({host=>'127.0.0.1',usr=>'root',pass=>'passwd',database=>'test_db'},{err_file=>'varloglogfile'});

    my $die_handler=EasyHandler->new(&die_to_file,['varloglogfile']);
    my $dba=EasyDBAccess->new({host=>'127.0.0.1',usr=>'root',pass=>'passwd',database=>'test_db'},{die_handler=>$die_handler});


    my $dbh=$dba->dbh();

    EasyDBAccess->once();
    $dba->once();

    $re=$dba->select_one('select id from person limit 0,1');
    #$re=1
    ($re,$err_code)=$dba->select_one('select id from person limit 0,1');
    #$re=1,$err_code=0
    ($re,$err_code)=$dba->select_one('select id from person2 limit 0,1');
    #table person2 doesn't exist, will die

    $dba->once();
    ($re,$err_code,$err_detail)=$dba->select_one('select id from person2 limit %start_pos,%count',{start_pos=>0,count=>1});
    #won't die, because we have do "$dba->once()" before it
    if($err_code==0){
    print "no error, id is $re";
    }elsif($err_code==5){
    #execute error
    if($dba->err_code()==1146){
    print 'table not exist';
    }else{
    #other error
    CORE::die $err_detail;
    }
    }

    ($re,$err_code)=$dba->execute('insert into person values (?,?)',[3,'Bob']);
    #1, affected_rows
    ($re,$err_code)=$dba->select('select * from person');
    #[{id=>1,name=>'tom'},{id=>2,name=>'gates'}]
    ($re,$err_code)=$dba->select_array('select * from person');
    #[[1,'tom'],[2,'gates']]
    ($re,$err_code)=$dba->select_row('select * from person');
    #{id=>1,name=>'tom'}
    ($re,$err_code)=$dba->select_col('select id from person');
    #[1,2]
    ($re,$err_code)=$dba->select_one('select id from person');
    #1, first line first column

    ($re,$err_code)=$dba->select_one('select name from person where id=3');
    #select_row, select_one can cause NO_LINE error
    if($err_code==0){
    print "no error, name is $re";
    }elsif($err_code==1){
    #no line
    print "there is 0 row in result set";
    }else{
    print "other error";
    }


    $id=$dba->id('key1');#1
    $id=$dba->id('key2');#1
    $id=$dba->id('key1');#2
    $id=$dba->id('key1');#3

    $sid=$dba->sid();
    #446d40ffd9890184
    $sid_info=$dba->sid_info('446d40ffd9890184');
    #{"sid" => 3649634692, "comment" => undef, "record_time" => 1148010751}

    #will insert a record to note table
    $sid->note('hello world');

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    database access | database interface | Perl module | Perl | database | access

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM