$out2 = $_POST[tbl_transactions::$out_amount . "2"];
     $cat2 = $_POST[tbl_transactions::$category . "2"];
     $desc2 = $_POST[tbl_transactions::$description . "2"];
     $tag2 = $_POST[tbl_transactions::$tag_id . "2"];
     $store2 = $_POST[tbl_transactions::$store_id . "2"];
     if ($in + $in2 != $originalIn) {
         throw new Exception("new amounts are not equal to original total amount of '" . $originalIn . "'");
     }
     if ($out + $out2 != $originalOut) {
         throw new Exception("new amounts are not equal to original total amount of '" . $originalOut . "'");
     }
     $insert = new MySqlInsert();
     $insert->INTO(tbl_transactions::tableName());
     $insert->COLUMNS(array(tbl_transactions::$tdate, tbl_transactions::$in_amount, tbl_transactions::$out_amount, tbl_transactions::$category, tbl_transactions::$description, tbl_transactions::$ttype, tbl_transactions::$tyear, tbl_transactions::$tmonth, tbl_transactions::$tday, tbl_transactions::$tag_id, tbl_transactions::$store_id));
     $insert->ADD_ROW(array($date, $in2, $out2, $cat2, $desc2, $type, $year, $month, $day, $tag2, $store2));
     Debug($insert->toString());
 }
 $update = new MySqlUpdate();
 $update->TABLE(tbl_transactions::tableName());
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$in_amount, $in);
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$out_amount, $out);
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$category, $cat);
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$description, $desc);
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$tag_id, $tag);
 $update->ADD_COLUMN_VALUE_PAIR(tbl_transactions::$store_id, $store);
 $update->ADD_CONDITION(tbl_transactions::getPrimaryKeyField() . "=" . $id);
 Debug($update->toString());
 if ($insert) {
     db::MySqlSubmitTransaction(array($update->toString(), $insert->toString()));
 } else {
     db::MySqlSubmitQuery($update->toString());
예제 #2
0
<?php

/*
Code to save a new store to the database.
*/
require_once "include_files.php";
$storeName = $_POST["sname"];
$storeDefaultTag = $_POST["stag"];
if ($storeName && $storeDefaultTag) {
    $insertStore = new MySqlInsert();
    $insertStore->INTO(tbl_stores::tableName());
    $insertStore->COLUMNS(array(tbl_stores::$store_name, tbl_stores::$default_tag_id));
    $insertStore->ADD_ROW(array($storeName, $storeDefaultTag));
    db::MySqlSubmitQuery($insertStore->toString());
    echo "Store '" . $storeName . "' added successfully.";
} else {
    echo "Empty or Invalid Store name '" . $storeName . "' provided";
}
예제 #3
0
                            $record_in_amount = getRowColumnValue($row, 1);
                        } else {
                            $record_out_amount = getRowColumnValue($row, 1) * -1;
                        }
                        $record_category = getRowColumnValue($row, 3);
                        $record_description = getRowColumnValue($row, 4);
                        $record_type = db_enum_ttype::c_checking;
                        $record_month = date($date_month, strtotime(getRowColumnValue($row, 0)));
                        $record_year = date($date_year, strtotime(getRowColumnValue($row, 0)));
                        $record_day = date($date_day, strtotime(getRowColumnValue($row, 0)));
                    }
                }
                $insertQuery->ADD_ROW(array($record_date, $record_in_amount, $record_out_amount, $record_category, $record_description, $record_type, $record_month, $record_year, $record_day));
            }
            fclose($handle);
        }
        // Query
        Debug($insertQuery->toString());
        db::MySqlSubmitQuery($insertQuery->toString());
        // Success
        echo "<img width='70' style='float:left' src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQfhIUgJquf8L02tVeh0B_Vfe_kOhbLofy5kpGs_CB4PEfakg8vGzk6lp75' /><h3>File uploaded successfully.</h3><a href='index.html'>Done</a>";
        echo "<br><br><a href='upload.php'>upload another...</a>";
        echo "<br><a href='tag_records.php?execute-tagging=1'><img src='http://www.iconsdb.com/icons/preview/orange/tag-xxl.png' style='width:20px' /> RUN TAGGING</a>";
    } catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
}
function getRowColumnValue($r, $columnIndex)
{
    return addslashes(trim(trim($r[$columnIndex]), '"'));
}