2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 01/22/2013 *
4 * =================== Last change: 01/22/2013 *
6 * -------------------------------------------------------------------- *
7 * File : pool-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for handling status codes *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen zum Umgang mit Status-Funktionen *
12 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
38 // "Getter" for pool data from given id number
39 // @TODO "Hook" ext-html_mail into this to allow column `html_msg`
40 function getPoolDataFromId ($poolId) {
44 // Search for pool data
45 $result = sqlQueryEscaped('SELECT
59 `{?_MYSQL_PREFIX?}_pool`
63 array(bigintval($poolId)), __FUNCTION__, __LINE__);
66 if (sqlNumRows($result) == 1) {
68 $content = sqlFetchArray($result);
72 sqlFreeResult($result);
79 function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $whereSql = '', $moreSql = '') {
80 // Is update mode set?
81 if (!is_null($updateMode)) {
82 // Don't allow array as data here
83 assert(!is_array($data));
85 // Then use this on the column with this mode (mostly counters)
86 sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
93 ), __FUNCTION__, __LINE__);
94 } elseif (is_array($data)) {
96 * Update multiple columns, $columnName and $updateMode are being
97 * ignored as last doesn't work and first is given in $data array.
99 $sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET ';
100 foreach ($data as $key => $value) {
102 $sql .= sprintf("`%s`='%s',", sqlEscapeString($key), sqlEscapeString($value));
106 $sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1';
108 // And finally run it
109 sqlQuery($sql, __FUNCTION__, __LINE__);
112 sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
117 ), __FUNCTION__, __LINE__);
120 // Return if it has an affected row
121 return (sqlAffectedRows() == 1);
124 // Insert data into pool and return its insert id
125 function insertDataIntoPool ($data) {
126 // Construct SQL query
127 $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')";
130 sqlQuery($sql, __FUNCTION__, __LINE__);
133 return getSqlInsertId();