Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / gl / includes / db / gl_db_currencies.inc
index 111b83dc8ee67a9612e055054a16a0d095d0ed92..b725c11318e2dec7300ad6247cdacbc91c89574e 100644 (file)
 ***********************************************************************/
 //---------------------------------------------------------------------------------------------
 
-function update_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
+function update_currency($curr_abrev, $symbol, $currency, $country, 
+       $hundreds_name, $auto_update)
 {
-       $sql = "UPDATE ".TB_PREF."currencies SET currency=".db_escape($currency).", curr_symbol='$symbol',
-               country=".db_escape($country).", hundreds_name=".db_escape($hundreds_name)." WHERE curr_abrev = '$curr_abrev'";
+       begin_transaction(__FUNCTION__, func_get_args());
+       $sql = "UPDATE ".TB_PREF."currencies SET currency=".db_escape($currency)
+               .", curr_symbol=".db_escape($symbol).", country=".db_escape($country)
+               .", hundreds_name=".db_escape($hundreds_name)
+               .",auto_update = ".db_escape($auto_update)
+                       ." WHERE curr_abrev = ".db_escape($curr_abrev);
 
        db_query($sql, "could not update currency for $curr_abrev");
+       commit_transaction();
 }
 
 //---------------------------------------------------------------------------------------------
 
-function add_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
+function add_currency($curr_abrev, $symbol, $currency, $country, 
+       $hundreds_name, $auto_update)
 {
-       $sql = "INSERT INTO ".TB_PREF."currencies (curr_abrev, curr_symbol, currency, country, hundreds_name)
-               VALUES (".db_escape($curr_abrev).", '$symbol', ".db_escape($currency).", ".db_escape($country).", ".db_escape($hundreds_name).")";
+       begin_transaction(__FUNCTION__, func_get_args());
+
+       $sql = "INSERT INTO ".TB_PREF."currencies (curr_abrev, curr_symbol, currency, 
+                       country, hundreds_name, auto_update)
+               VALUES (".db_escape($curr_abrev).", ".db_escape($symbol).", "
+               .db_escape($currency).", ".db_escape($country).", "
+               .db_escape($hundreds_name).",".db_escape($auto_update).")";
 
        db_query($sql, "could not add currency for $curr_abrev");
+
+       $result = db_insert_id();
+       commit_transaction();
+       return $result;
 }
 
 //---------------------------------------------------------------------------------------------
 
 function delete_currency($curr_code)
 {
-       $sql="DELETE FROM ".TB_PREF."currencies WHERE curr_abrev='$curr_code'";
+       begin_transaction(__FUNCTION__, func_get_args());
+
+       $sql="DELETE FROM ".TB_PREF."currencies WHERE curr_abrev=".db_escape($curr_code);
        db_query($sql, "could not delete currency       $curr_code");
 
        $sql="DELETE FROM ".TB_PREF."exchange_rates WHERE curr_code='$curr_code'";
        db_query($sql, "could not delete exchange rates for currency $curr_code");
+
+       commit_transaction();
 }
 
 //---------------------------------------------------------------------------------------------
 
 function get_currency($curr_code)
 {
-       $sql = "SELECT * FROM ".TB_PREF."currencies WHERE curr_abrev='$curr_code'";
+       $sql = "SELECT * FROM ".TB_PREF."currencies WHERE curr_abrev=".db_escape($curr_code);
        $result = db_query($sql, "could not get currency $curr_code");
 
        $row = db_fetch($result);
@@ -60,6 +80,3 @@ function get_currencies($all=false)
        return db_query($sql, "could not get currencies");
 }
 
-//---------------------------------------------------------------------------------------------
-
-?>
\ No newline at end of file