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 > Perl Modules

    Teng::Plugin::SearchBySQLAbstractMore 0.08

    Download button

    No screenshots available
    Downloads: 158  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Ktat | More programs
    GPL / FREE
    September 23rd, 2012, 10:23 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Teng::Plugin::SearchBySQLAbstractMore description

    Use SQL::AbstractMore as Query Builder for Teng

    Teng::Plugin::SearchBySQLAbstractMore is a Perl module to use SQL::AbstractMore as Query Builder for Teng

    SYNOPSIS

      package MyApp::DB;
      use parent qw/Teng/;
      __PACKAGE__->load_plugin('SearchBySQLAbstractMore');

      package main;
      my $db = MyApp::DB->new(dbh => $dbh);
      my $page = $c->req->param('page') || 1;
      my ($rows, $pager) = $db->search_by_sql_abstract_more('user' => {type => 3}, {page => $page, rows => 5});


    If you want to replace Teng search

      package MyApp::DB;
      use parent qw/Teng/;
      __PACKAGE__->load_plugin('SearchBySQLAbstractMore');
      __PACKAGE__->install_sql_abstract_more;
      # now, search method is replaced by search_by_sql_abstract_more


    If you want to load pager at the same time

      # search_with_pager from SearchBySQLAbstractMore::Pager
      __PACKAGE__->install_sql_abstract_more(pager => 'Pager');
      # search_with_pager from SearchBySQLAbstractMore::Pager::MySQLFoundRows
      __PACKAGE__->install_sql_abstract_more(pager => 'Pager::MySQLFoundRows');


    Create complex SQL using SQL::Abstract::More.

    Compatible usage with Teng's search method.

     $teng->search_by_sql_abstract_more
        ('table1',
         { name => { like => '%perl%'},
           -and => [
                    {x => 1},
                    {y => [-or => {'>' => 2}, {'< ' = > 10}]},
                   ],
         },
         {
          from     => ['-join',
                       'table1|t1',
                       't1.id=t2.id',
                       'table2|t2',
                       't1.id=t3.table1_id,t2.id=t3.table2_id',
                       'table3|t3',
                      ],
          columns  => ['x', 'y', 'min(age) as min_age', 'max(age) as max_age'],
          group_by => ['x', 'y'],
          having   => {'max_age' => {'< ' = > 10}},
         },
        );
     # SELECT x, y, min(age) as min_age, max(age) as max_age
     #   FROM table1 AS t1
     #     INNER JOIN table2 AS t2 ON ( t1.id = t2.id )
     #     INNER JOIN table3 AS t3 ON ( ( t1.id = t3.table1_id AND t2.id = t3.table2_id ) )
     #   WHERE ( ( ( x = ? AND ( y > ? OR y < ? ) ) AND name LIKE ? ) )
     #   GROUP BY x, y  HAVING ( max_age < ? );


    SQL::Abstract::More original usage(as first argument, use hash ref instead of teble name):

     $teng->search_by_sql_abstract_more(
       {
         -columns  => ['x', 'y', 'min(age) as min_age', 'max(age) as max_age'],
         -from     => [-join,
                       'table1|t1',
                       't1.id=t2.id',
                       'table2|t2',
                       't1.id=t3.table1_id,t2.id=t3.table2_id',
                       'table3|t3',
                     ],
         -group_by => ['x', 'y'],
         -having   => {'max_age' => {'< ' = > 10'}},
         -where => {
            name => { like => '%perl%'},
            -and => [
                {x => 1},
                {y => [-or => {'>' => 2}, {'< ' = > 10}]},
            ],
          },
       },
     );
     # SQL is as same as the avobe code.


    Using pager.

    Compatible usage:

     $teng->search_by_sql_abstract_more(
       'table', {
         name => 1,
         age  => 10,
       },
       {
         -columns  => ['x', 'y'],
         -from     => ['table'],
         -page     => 2,
         -rows     => 20,
       },
     );


    Originaly usage:

     $teng->search_by_sql_abstract_more(
       {
         -columns  => ['x', 'y'],
         -from     => ['table'],
         -where    => {
              name => 1,
              age  => 10,
         },
         -page     => 2,
         -rows     => 20,
       },
     );



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    query builder | Perl module | Teng | query | builder

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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