/** * Frees a result set. * * @param resource $res The database query resource returned from * the {@link dbi_query()} function. * * @return bool True on success */ function dbi_free_result($res) { if (strcmp($GLOBALS["db_type"], "mysql") == 0) { return mysql_free_result($res); } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { return mysqli_free_result($res); } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { return mssql_free_result($res); } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { // Not supported. Ingore. if ($GLOBALS["oracle_statement"] >= 0) { OCIFreeStatement($GLOBALS["oracle_statement"]); $GLOBALS["oracle_statement"] = -1; } } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { return pg_freeresult($res); } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { return odbc_free_result($res); } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { return db2_free_result($res); } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { return ibase_free_result($res); } else { dbi_fatal_error("dbi_free_result(): db_type not defined."); } } } } } } } } }
function dbi_clear_cache() { global $db_connection_info; if (empty($db_connection_info['cachedir'])) { return 0; } $cnt = 0; $fd = @opendir($db_connection_info['cachedir']); if (empty($fd)) { dbi_fatal_error(translate('Error opening cache dir') . ': ' . $db_connection_info['cachedir']); } $b = 0; $errcnt = 0; $errstr = ''; while (false !== ($file = readdir($fd))) { if (preg_match('/^\\S\\S\\S\\S\\S\\S\\S\\S\\S\\S+.dat$/', $file)) { // echo 'Deleting ' . $file . '<br />'; $cnt++; $fullpath = $db_connection_info['cachedir'] . '/' . $file; $b += filesize($fullpath); if (!@unlink($fullpath)) { $errcnt++; $errstr .= '<!-- ' . translate('Error') . ': ' . str_replace('XXX', translate('delete'), translate('Could not XXX file')) . " {$file}. -->\n"; // TODO: log this somewhere??? } } } if ($errcnt > 10) { // They don't have correct permissions set. die_miserable_death("Error removing temporary file.<br/><br/>The permissions for the following directory do not support the db_cachedir option in includes/settings.php:<br/><blockquote>" . $db_connection_info['cachedir'] . "</blockquote>", 'dbCacheError'); } return $cnt; }