Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / admin / what-list_country.php
index 8373690f78b0b0e141c29a584947460bb6db9371..93a5d73c87e94246efdec0fb8733bd25c16826d1 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -46,11 +46,11 @@ addYouAreHereLink('admin', __FILE__);
 // Add new code?
 if ((isFormSent('add')) && (isPostRequestElementSet('code')) && (isPostRequestElementSet('descr'))) {
        // Check if country code does already exist
-       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `code`='%s' LIMIT 1",
+       $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `code`='%s' LIMIT 1",
        array(strtoupper(postRequestElement('code'))), __FILE__, __LINE__);
-       if (SQL_HASZERONUMS($result)) {
+       if (ifSqlHasZeroNumRows($result)) {
                // Save entry
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (`code`, `descr`, `is_active`) VALUES ('%s','%s','%s')",
+               sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (`code`, `descr`, `is_active`) VALUES ('%s','%s','%s')",
                array(
                        strtoupper(substr(postRequestElement('code'), 0, 2)),
                        postRequestElement('descr'),
@@ -61,7 +61,7 @@ if ((isFormSent('add')) && (isPostRequestElementSet('code')) && (isPostRequestEl
                $message = '{%message,ADMIN_COUNTRY_ADDED=' . strtoupper(postRequestElement('descr')) . '%}';
        } else {
                // Free memory
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
 
                // Does already exist
                $message = '{%message,ADMIN_COUNTRY_ALREADY=' . strtoupper(postRequestElement('code')) . '%}';
@@ -104,11 +104,11 @@ if ((isFormSent('add')) && (isPostRequestElementSet('code')) && (isPostRequestEl
                $OUT = '';
                foreach (postRequestElement('id') as $id => $isActive) {
                        // Load data from DB
-                       $result = SQL_QUERY_ESC("SELECT `id`, `code`, `descr` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1",
+                       $result = sqlQueryEscaped("SELECT `id`, `code`, `descr` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1",
                                array(bigintval($id)), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result) == 1) {
+                       if (sqlNumRows($result) == 1) {
                                // Load data
-                               $content = SQL_FETCHARRAY($result);
+                               $content = sqlFetchArray($result);
 
                                // Add $isActive
                                $content['is_active'] = $isActive;
@@ -118,7 +118,7 @@ if ((isFormSent('add')) && (isPostRequestElementSet('code')) && (isPostRequestEl
                        } // END - if
 
                        // Free result
-                       SQL_FREERESULT($result);
+                       sqlFreeResult($result);
                } // END - foreach
 
                // Prepare content for template
@@ -173,20 +173,20 @@ LIMIT 1");
        } // END - if
 
        // Load currenty setup country codes to list
-       $result = SQL_QUERY('SELECT `id`, `code`, `descr`, `is_active` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `code` ASC',
+       $result = sqlQuery('SELECT `id`, `code`, `descr`, `is_active` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `code` ASC',
                __FILE__, __LINE__);
 
        // Are there entries?
-       if (!SQL_HASZERONUMS($result)) {
+       if (!ifSqlHasZeroNumRows($result)) {
                // List all countries
                $OUT = '';
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Load row template and switch colors
                        $OUT .= loadTemplate('admin_list_country_row', TRUE, $content);
                } // END - while
 
                // Free memory
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
        } else {
                // No code setup so far (not possible by this software! 'DE' for 'Deutschland' is default
                $OUT = loadTemplate('admin_list_country_no_row', TRUE);
@@ -195,9 +195,6 @@ LIMIT 1");
        // Add list to constant for the template
        $content['rows'] = $OUT;
 
-       // Include add template
-       $content['add_form'] = loadTemplate('admin_add_country', TRUE);
-
        // Load main template
        loadTemplate('admin_list_country', FALSE, $content);
 }