From: Roland Häder Date: Wed, 12 Jun 2013 01:10:47 +0000 (+0000) Subject: MySQLi support added (very basic): X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b52976057a73d26d63b6c98a4fc9efb3e07f40e7;p=mailer.git MySQLi support added (very basic): - Added very basic MySQLi module as MySQL extension is becoming deprecated - Module for listing network API cache added - Other minor fixes to get MySQLi working --- diff --git a/.gitattributes b/.gitattributes index bff1090714..813cd72c83 100644 --- a/.gitattributes +++ b/.gitattributes @@ -148,6 +148,7 @@ inc/daily/daily_yoomedia.php svneol=native#text/plain inc/databases.php svneol=native#text/plain inc/db/.htaccess svneol=native#text/plain inc/db/lib-mysql3.php svneol=native#text/plain +inc/db/lib-mysqli.php svneol=native#text/plain inc/db/lib.php svneol=native#text/plain inc/debug/.htaccess svneol=native#text/plain inc/debug/client/.htaccess svneol=native#text/plain @@ -651,6 +652,7 @@ inc/modules/admin/what-list_grade_data.php svneol=native#text/plain inc/modules/admin/what-list_holiday.php svneol=native#text/plain inc/modules/admin/what-list_links.php svneol=native#text/plain inc/modules/admin/what-list_mods.php svneol=native#text/plain +inc/modules/admin/what-list_network_api.php svneol=native#text/plain inc/modules/admin/what-list_network_array_translation.php svneol=native#text/plain inc/modules/admin/what-list_network_data.php svneol=native#text/plain inc/modules/admin/what-list_network_request_params.php svneol=native#text/plain @@ -2255,6 +2257,7 @@ templates/xml/admin/admin_list_forced_ads.xml svneol=native#text/plain templates/xml/admin/admin_list_forced_campaigns.xml svneol=native#text/plain templates/xml/admin/admin_list_forced_costs.xml svneol=native#text/plain templates/xml/admin/admin_list_grade_data.xml svneol=native#text/plain +templates/xml/admin/admin_list_network_api.xml svneol=native#text/plain templates/xml/admin/admin_list_network_query_api_config.xml svneol=native#text/plain templates/xml/admin/admin_list_nickname_history.xml svneol=native#text/plain templates/xml/admin/admin_list_point_accounts.xml svneol=native#text/plain diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 3a8c1108a3..24fb6e42c8 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -94,7 +94,7 @@ function sqlQuery ($sqlString, $file, $line, $enableCodes = TRUE) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($file) . ',line=' . $line . ',sql=' . $GLOBALS['last_sql']); $result = mysql_query($GLOBALS['last_sql'], getSqlLink()) or sqlError($file, $line, 'file='. basename($file) . ',line=' . $line . ':mysql_error()=' . mysql_error() . ',last_query=' . $GLOBALS['last_sql']); - //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(is_resource($result) ? sqlNumRows($result) : gettype($result))); + //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlLink($result) ? sqlNumRows($result) : gettype($result))); // Calculate query time $queryTime = microtime(TRUE) - $querytimeBefore; @@ -121,7 +121,7 @@ function sqlQuery ($sqlString, $file, $line, $enableCodes = TRUE) { } // END - if // Append debug line - appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (is_resource($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql'])); + appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (isValidSqlLink($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql'])); } // END - if // Increment stats entry @@ -143,7 +143,7 @@ function sqlNumRows ($resource) { if (isset($GLOBALS['sql_numrows'][intval($resource)])) { // Use cache $lines = $GLOBALS['sql_numrows'][intval($resource)]; - } elseif (is_resource($resource)) { + } elseif (isValidSqlLink($resource)) { // Get the count of rows from database $lines = mysql_num_rows($resource); @@ -173,7 +173,7 @@ function sqlAffectedRows () { // SQL fetch row function sqlFetchRow ($resource) { // Is $resource valid? - if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE; + if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE; // Fetch the data and return it return mysql_fetch_row($resource); @@ -182,7 +182,7 @@ function sqlFetchRow ($resource) { // SQL fetch array function sqlFetchArray ($resource) { // Is $resource valid? - if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE; + if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE; // Load row as array from database $row = mysql_fetch_assoc($resource); @@ -200,7 +200,7 @@ function sqlFetchArray ($resource) { // SQL result function sqlResult ($resource, $row, $field = '0') { // Is $resource valid? - if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE; + if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE; // Run the result command $result = mysql_result($resource, $row, $field); @@ -215,7 +215,7 @@ function sqlConnectToDatabase ($host, $login, $password, $file, $line) { $linkResource = mysql_connect($host, $login, $password) or sqlError($file, $line, mysql_error()); // Set the link resource - if (is_resource($linkResource)) { + if (isValidSqlLink($linkResource)) { /* * A non-resource (boolean) may happen on installation phase which * shall not be set here. Only valid link resources shall be set so @@ -270,7 +270,7 @@ function sqlCloseLink ($file, $line) { // SQL free result function sqlFreeResult ($resource) { - if ((!is_resource($resource)) || (!isSqlLinkUp())) { + if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) { // Abort here return FALSE; } // END - if @@ -386,5 +386,11 @@ function sqlError ($file, $line, $message) { } } +// Checks whether given link is a valid SQL link +function isValidSqlLink ($linkResource) { + // Is it a resource? + return is_resource($linkResource); +} + // [EOF] ?> diff --git a/inc/db/lib-mysqli.php b/inc/db/lib-mysqli.php new file mode 100644 index 0000000000..85e9c0a03c --- /dev/null +++ b/inc/db/lib-mysqli.php @@ -0,0 +1,390 @@ + diff --git a/inc/language/network_de.php b/inc/language/network_de.php index ea1e662c34..240d8fe9c6 100644 --- a/inc/language/network_de.php +++ b/inc/language/network_de.php @@ -328,6 +328,8 @@ addMessages(array( 'ADMIN_QUERY_NETWORK_TYPE' => "Einzelnen Werbeart-Handler abfragen", 'ADMIN_ACTION_QUERY_ALL_NETWORK_APIS_SUBMIT' => "Alle ausgewählten Werbeart-Handler abfragen", 'ADMIN_NETWORK_QUERY_TYPE_OKAY' => "Das Werbenetzwerk %s wurde soeben abgefragt. Die Daten wurden zwischengespeichert für spätere Verwendung und um die API-Anfragen zu reduzieren.", + // List API cache + 'ADMIN_NETWORK_API_CACHE_404' => "Keinen API-Cache gefunden, da keine APIs abgefragt wurden.", // Error codes 'ADMIN_NETWORK_AFF_ID_PASS_WRONG_ERROR_CODE' => "Affiliate-Id oder -Passwort falsch", 'ADMIN_NETWORK_SITE_ID_NOT_ASSIGNED_ERROR_CODE' => "Seiten-Id nicht zugewiesen/ungültig", diff --git a/inc/modules/admin/what-list_network_api.php b/inc/modules/admin/what-list_network_api.php new file mode 100644 index 0000000000..7739a92e78 --- /dev/null +++ b/inc/modules/admin/what-list_network_api.php @@ -0,0 +1,55 @@ + diff --git a/inc/sql-functions.php b/inc/sql-functions.php index 8e64bc0df0..b0fa506517 100644 --- a/inc/sql-functions.php +++ b/inc/sql-functions.php @@ -501,16 +501,16 @@ function setSqlLink ($file, $line, $link) { if ((ifFatalErrorsDetected()) && (isInstaller())) { // This may happen in installation phase return; - } elseif ((!is_resource($link)) && (!is_null($link))) { + } elseif ((!is_resource($link)) && (!is_null($link)) && (!$link instanceof mysqli)) { // This should never happen! - reportBug($file . ':' . __FUNCTION__, $line . ':' . __LINE__, sprintf('Type of link is not resource or null, type=%s', gettype($link))); + reportBug($file . ':' . __FUNCTION__, $line . ':' . __LINE__, sprintf('Type of link is not resource, null or mysqli class, type=%s', gettype($link))); } // END - if // Set it $GLOBALS['__sql_link'] = $link; // Re-init cache - $GLOBALS['__is_sql_link_up'] = is_resource($link); + $GLOBALS['__is_sql_link_up'] = isValidSqlLink($link); } // Checks if the link is up diff --git a/templates/xml/admin/admin_list_network_api.xml b/templates/xml/admin/admin_list_network_api.xml new file mode 100644 index 0000000000..4af399a25e --- /dev/null +++ b/templates/xml/admin/admin_list_network_api.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +