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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // "Getter" for pool data from given id number
44 // @TODO "Hook" ext-html_mail into this to allow column `html_msg`
45 function getPoolDataFromId ($poolId) {
49 // Search for pool data
50 $result = sqlQueryEscaped('SELECT
64 `{?_MYSQL_PREFIX?}_pool`
68 array(bigintval($poolId)), __FUNCTION__, __LINE__);
71 if (sqlNumRows($result) == 1) {
73 $content = sqlFetchArray($result);
77 sqlFreeResult($result);
84 function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $whereSql = '', $moreSql = '') {
85 // Is update mode set?
86 if (!is_null($updateMode)) {
87 // Don't allow array as data here
88 assert(!is_array($data));
90 // Then use this on the column with this mode (mostly counters)
91 sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
98 ), __FUNCTION__, __LINE__);
99 } elseif (is_array($data)) {
101 * Update multiple columns, $columnName and $updateMode are being
102 * ignored as last doesn't work and first is given in $data array.
104 $sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET ';
105 foreach ($data as $key => $value) {
107 $sql .= sprintf("`%s`='%s',", sqlEscapeString($key), sqlEscapeString($value));
111 $sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1';
113 // And finally run it
114 sqlQuery($sql, __FUNCTION__, __LINE__);
117 sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
122 ), __FUNCTION__, __LINE__);
125 // Return if it has an affected row
126 return (sqlAffectedRows() == 1);
129 // Insert data into pool and return its insert id
130 function insertDataIntoPool ($data) {
131 // Construct SQL query
132 $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')";
135 sqlQuery($sql, __FUNCTION__, __LINE__);
138 return getSqlInsertId();