Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r10985: LJSUP-9763 (create an admin page to view...

Committer: ailyin
LJSUP-9763 (create an admin page to view recent selfpromo promotions)
U   trunk/cgi-bin/LJ/Pay/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2011-09-09 04:19:57 UTC (rev 10984)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2011-09-09 09:06:31 UTC (rev 10985)
@@ -351,6 +351,7 @@
 
     my @where = (1);
     my @binds;
+    my ( $sort_cond, $limit_cond ) = ( '', '' );
 
     if ( my $started_min = delete $params->{'started_min'} ) {
         push @where, 'started > ?';
@@ -362,15 +363,28 @@
         push @binds, $promoid;
     }
 
+    if ( my $promoid_max = delete $params->{'promoid_max'} ) {
+        push @where, 'promoid < ?';
+        push @binds, $promoid_max;
+    }
+
     if ( delete $params->{'require_active'} ) {
         push @where, 'active = 1';
     }
 
+    if ( my $sort = delete $params->{'sort'} ) {
+        $sort_cond = "ORDER BY $sort";
+    }
+
+    if ( my $limit = delete $params->{'limit'} ) {
+        $limit_cond = "LIMIT $limit";
+    }
+
     my $where_sql = join( ' AND ', @where );
 
     my $dbh = LJ::get_db_writer();
     my $rows = $dbh->selectall_arrayref(
-        "SELECT * FROM selfpromo WHERE $where_sql",
+        "SELECT * FROM selfpromo WHERE $where_sql $sort_cond $limit_cond",
         { 'Slice' => {} }, @binds,
     );
 

Tags: andy, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments