More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / modules / admin / what-list_sponsor_pay.php
index 3709b0f646a7ed18cc7bef52c5b7e77236ba2d5e..dee8f22e8c23bfecee08533590b697127b7622c3 100644 (file)
@@ -142,21 +142,11 @@ if (isFormSent('add')) {
        $OUT = '';
        foreach (postRequestParameter('id') as $id => $sel) {
                // Load entry
-               $result = SQL_QUERY_ESC("SELECT `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`='%s' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Load data
-                       list($name, $rate, $min, $curr) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-
-                       // Transfer data to array
-                       $content = array(
-                               'id'   => bigintval($id),
-                               'name' => htmlspecialchars($name),
-                               'rate' => translateComma($rate),
-                               'min'  => bigintval($min),
-                               'curr' => htmlspecialchars($curr)
-                       );
+                       $content = SQL_FETCHARRAY($result);
 
                        if (isFormSent('edit')) {
                                // Edit entry
@@ -169,6 +159,9 @@ if (isFormSent('add')) {
                        // Entry invalid
                        $OUT .= loadTemplate('admin_list_sponsor_pay_404', true, $id);
                }
+
+               // Free result
+               SQL_FREERESULT($result);
        } // END - foreach
 
        // Load main template depending on mode (edit/delete)
@@ -190,21 +183,12 @@ ORDER BY
                __FILE__, __LINE__);
 
        // Do we have some paytypes setup?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Prepare variables for listing
                $OUT = '';
 
                // List alle found payment types
                while ($content = SQL_FETCHARRAY($result)) {
-                       // Remember data in array
-                       $content = array(
-                               'id'       => $content['id'],
-                               'name'     => $content['pay_name'],
-                               'rate'     => translateComma($content['pay_rate']),
-                               'min'      => $content['pay_min_count'],
-                               'currency' => $content['pay_currency']
-                       );
-
                        // Add row
                        $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
                } // END - while