X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fpool-functions.php;h=1bfc33bfc48411f2ff0bfe8ac99942f7977b45b3;hb=936a7baf6967cd03d65a84acef3b9b4de8fcec6a;hp=81a303eea527037197153eebb00cb08ec5ab1cde;hpb=c0c6d5d58bdecd22bdcf7dfe5b24bec69e1810c7;p=mailer.git diff --git a/inc/pool-functions.php b/inc/pool-functions.php index 81a303eea5..1bfc33bfc4 100644 --- a/inc/pool-functions.php +++ b/inc/pool-functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -47,7 +47,7 @@ function getPoolDataFromId ($poolId) { $content = array(); // Search for pool data - $result = SQL_QUERY_ESC('SELECT + $result = sqlQueryEscaped('SELECT `id`, `sender`, `subject`, @@ -68,13 +68,13 @@ LIMIT 1', array(bigintval($poolId)), __FUNCTION__, __LINE__); // Is there an entry? - if (SQL_NUMROWS($result) == 1) { + if (sqlNumRows($result) == 1) { // Load data - $content = SQL_FETCHARRAY($result); + $content = sqlFetchArray($result); } // END - if // Free result - SQL_FREERESULT($result); + sqlFreeResult($result); // Return found data return $content; @@ -88,7 +88,7 @@ function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $w assert(!is_array($data)); // Then use this on the column with this mode (mostly counters) - SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1', + sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1', array( $columnName, $columnName, @@ -104,17 +104,17 @@ function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $w $sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET '; foreach ($data as $key => $value) { // Add it - $sql .= sprintf("`%s`='%s',", SQL_ESCAPE($key), SQL_ESCAPE($value)); + $sql .= sprintf("`%s`='%s',", sqlEscapeString($key), sqlEscapeString($value)); } // END - foreach // Finish SQL $sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1'; // And finally run it - SQL_QUERY($sql, __FUNCTION__, __LINE__); + sqlQuery($sql, __FUNCTION__, __LINE__); } else { // Regular update - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1', + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1', array( $columnName, $data, @@ -123,7 +123,19 @@ function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $w } // Return if it has an affected row - return (SQL_AFFECTEDROWS() == 1); + return (sqlAffectedRows() == 1); +} + +// Insert data into pool and return its insert id +function insertDataIntoPool ($data) { + // Construct SQL query + $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')"; + + // Run the query + sqlQuery($sql, __FUNCTION__, __LINE__); + + // Return insert id + return getSqlInsertId(); } // [EOF]