$data['cat'] = '{--_CATEGORY_NONE--}';
} elseif ($cid > 0) {
// Lookup the category in database
- $result = SQL_QUERY_ESC("SELECT `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1",
+ $result = SQL_QUERY_ESC('SELECT `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1',
array(bigintval($cid)), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Category found... :-)
// Get a string of "mail title" and price back
function getPaymentTitlePrice ($pid, $full = false) {
- // Default is not found
- $ret = '{--_PAYMENT_404--}';
-
- // Load payment data
- $result = SQL_QUERY_ESC("SELECT `mail_title`,`price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
- array(
- bigintval($pid)
- ), __FUNCTION__, __LINE__);
-
- // Do we have an entry?
- if (SQL_NUMROWS($result) == 1) {
- // Payment type found... :-)
- $data = SQL_FETCHARRAY($result);
-
- // Only title or also including price?
- if ($full === false) {
- $ret = $data['mail_title'];
- } else {
- $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}';
- }
- } // END - if
-
- // Free result
- SQL_FREERESULT($result);
+ // Only title or also including price?
+ if ($full === false) {
+ $ret = getPaymentData($pid, 'main_title');
+ } else {
+ $ret = getPaymentData($pid, 'main_title') . ' / {%pipe,getPaymentData,translateComma=' . $pid . '%} {?POINTS?}';
+ }
// Return result
return $ret;
}
-// Get (basicly) the price of given payment id
-function getPaymentPoints ($pid, $lookFor = 'price') {
+// "Getter" for payment data (cached)
+function getPaymentData ($pid, $lookFor = 'price') {
// Default value...
- $data[$lookFor] = -1;
+ $data[$lookFor] = NULL;
- // Search for it in database
- $result = SQL_QUERY_ESC("SELECT `%s` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
- array(
- $lookFor,
- bigintval($pid)
- ), __FUNCTION__, __LINE__);
+ // Do we have cache?
+ if (isset($GLOBALS['cache_array']['payments']['id'][$pid])) {
+ // Use it if found to save SQL queries
+ die('<pre>'.print_r($GLOBALS['cache_array']['payments'],true).'</pre>');
+ $data[$lookFor] = $GLOBALS['cache_array']['payments'][$lookFor][$pid];
- // Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
- // Payment type found... :-)
- $data = SQL_FETCHARRAY($result);
- } // END - if
+ // Update cache hits
+ incrementStatsEntry('cache_hits');
+ } elseif (!isExtensionActive('cache')) {
+ // Search for it in database
+ $result = SQL_QUERY_ESC('SELECT `%s` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1',
+ array(
+ $lookFor,
+ bigintval($pid)
+ ), __FUNCTION__, __LINE__);
- // Free result
- SQL_FREERESULT($result);
+ // Is the entry there?
+ if (SQL_NUMROWS($result) == 1) {
+ // Payment type found... :-)
+ $data = SQL_FETCHARRAY($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ }
// Return value
return $data[$lookFor];
// Update 'mails_sent' if sql_patches is updated
if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
// Update the pool
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1",
+ SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1',
array(bigintval($poolId)), __FUNCTION__, __LINE__);
} // END - if
$ret = 'done';
// Count or sum whole table?
if ($countRows === true) {
// Count whole table
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
+ $result = SQL_QUERY_ESC('SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
), __FUNCTION__, __LINE__);
} else {
// Sum whole table
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
+ $result = SQL_QUERY_ESC('SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
$tableName