Softpedia
 


LINUX CATEGORIES:



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

    Relations::Family 0.94

    Download button

    No screenshots available
    Downloads: 241  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Relations::Family team | More programs
    Perl Artistic License / FREE
    June 9th, 2007, 00:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Relations::Family description

    Relations::Family is a DBI/DBD::mysql Relational Query Engine module.

    Relations::Family is a DBI/DBD::mysql Relational Query Engine module.

    SYNOPSIS

    # DBI, Relations::Family Script that creates some queries.

    #!/usr/bin/perl

    use DBI;
    use Relations::Family;

    $dsn = "DBI:mysql:finder";

    $username = "root";
    $password = '';

    $dbh = DBI->connect($dsn,$username,$password,{PrintError => 1, RaiseError => 0});

    $abstract = new Relations::Abstract($dbh);

    $family = new Relations::Family($abstract);

    $family->add_member(-name => 'account',
    -label => 'Cust. Account',
    -database => 'finder',
    -table => 'account',
    -id_field => 'acc_id',
    -query => {-select => {'id' => 'acc_id',
    'label' => "concat(cust_name,' - ',balance)"},
    -from => ['account','customer'],
    -where => "customer.cust_id=account.cust_id",
    -order_by => "cust_name"});

    $family->add_member(-name => 'customer',
    -label => 'Customer',
    -database => 'finder',
    -table => 'customer',
    -id_field => 'cust_id',
    -query => {-select => {'id' => 'cust_id',
    'label' => 'cust_name'},
    -from => 'customer',
    -order_by => "cust_name"});

    $family->add_member(-name => 'purchase',
    -label => 'Purchase',
    -database => 'finder',
    -table => 'purchase',
    -id_field => 'pur_id',
    -query => {-select => {'id' => 'pur_id',
    'label' => "concat(
    cust_name,
    ' - ',
    date_format(date, '%M %D, %Y')
    )"},
    -from => ['purchase',
    'customer'],
    -where => 'customer.cust_id=purchase.cust_id',
    -order_by => ['date desc',
    'cust_name']});

    $family->add_lineage(-parent_name => 'customer',
    -parent_field => 'cust_id',
    -child_name => 'purchase',
    -child_field => 'cust_id');

    $family->add_rivalry(-brother_name => 'customer',
    -brother_field => 'cust_id',
    -sister_name => 'account',
    -sister_field => 'cust_id');

    $family->set_chosen(-label => 'Customer',
    -ids => '2,4');

    $available = $family->get_available(-label => 'Purchase');

    print "Found $available->{count} Purchases:n";

    foreach $id (@{$available->{ids_array}}) {

    print "Id: $id Label: $available->{labels_hash}->{$id}n";

    }

    $family->add_value(-name => 'Cust. Account',
    -sql => "concat(cust_name,' - ',balance)",
    -member_names => 'customer,account');

    $family->add_value(-name => 'Paid',
    -sql => "if(balance > 0,'NO','YES')",
    -member_names => 'account');

    $family->add_value(-name => 'Customer',
    -sql => 'cust_name',
    -member_names => 'customer');

    $family->add_value(-name => 'Purchase',
    -sql => "concat(
    cust_name,
    ' - ',
    date_format(date, '%M %D, %Y')
    )",
    -member_names => 'purchase,customer');

    $reunion = $family->get_reunion(-data => 'Paid,Purchase',
    -use_labels => 'Customer',
    -order_by => 'Customer,Purchase');

    $matrix = $abstract->select_matrix(-query => $reunion);

    print "Found " . scalar @$matrix . " Values:n";

    foreach $row (@$matrix) {

    print "Customer: $row->{'Customer'}n";
    print "Purchase: $row->{'Purchase'}n";
    print "Paid: $row->{'Paid'}nn";

    }

    $dbh->disconnect();

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    DBD::mysql query | query engine | Perl module | Relations::Family | DBD::mysql | database

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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