예제 #1
0
function dbInsert($data, $table)
{
    global $fullSql;
    // the following block swaps the parameters if they were given in the wrong order.
    // it allows the method to work for those that would rather it (or expect it to)
    // follow closer with SQL convention:
    // insert into the TABLE this DATA
    if (is_string($data) && is_array($table)) {
        $tmp = $data;
        $data = $table;
        $table = $tmp;
        //trigger_error('QDB - Parameters passed to insert() were in reverse order, but it has been allowed', E_USER_NOTICE);
    }
    $sql = 'insert into ' . $table . ' (' . implode(',', array_keys($data)) . ') values(' . implode(',', dbPlaceHolders($data)) . ')';
    dbBeginTransaction();
    $result = dbQuery($sql, $data);
    if ($result) {
        $id = mysql_insert_id();
        dbCommitTransaction();
        return $id;
    } else {
        if ($table != 'Contact') {
            trigger_error('QDB - Insert failed.', E_WARNING);
        }
        dbRollbackTransaction();
        return false;
    }
}
예제 #2
0
function dbInsert($data, $table)
{
    global $fullSql, $database_link;
    global $db_stats;
    // the following block swaps the parameters if they were given in the wrong order.
    // it allows the method to work for those that would rather it (or expect it to)
    // follow closer with SQL convention:
    // insert into the TABLE this DATA
    if (is_string($data) && is_array($table)) {
        $tmp = $data;
        $data = $table;
        $table = $tmp;
        // trigger_error('QDB - Parameters passed to insert() were in reverse order, but it has been allowed', E_USER_NOTICE);
    }
    $sql = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($data)) . '`)  VALUES (' . implode(',', dbPlaceHolders($data)) . ')';
    $time_start = microtime(true);
    dbBeginTransaction();
    $result = dbQuery($sql, $data);
    if ($result) {
        $id = mysqli_insert_id($database_link);
        dbCommitTransaction();
        // return $id;
    } else {
        if ($table != 'Contact') {
            trigger_error('QDB - Insert failed.', E_USER_WARNING);
        }
        dbRollbackTransaction();
        // $id = false;
    }
    // logfile($fullSql);
    $time_end = microtime(true);
    $db_stats['insert_sec'] += number_format($time_end - $time_start, 8);
    $db_stats['insert']++;
    return $id;
}
                    echo '</div>';
                    // Run all stored procedures in the database
                    // Doing so AFTER running the ExecEngine allows any problems with stored procedures to be 'fixed'
                    // 2do this: create a rule with the same ruleexpression and handle the violation with th ExecEngine
                    runAllProcedures();
                    runAllProcedures();
                    echo '<div id="InvariantRuleResults">';
                    $invariantRulesHold = checkInvariantRules();
                    echo '</div>';
                    if ($invariantRulesHold) {
                        setTimeStamp();
                        emitLog("COMMIT");
                        dbCommitTransaction();
                    } else {
                        emitLog("ROLLBACK");
                        dbRollbackTransaction();
                    }
                    echo '</div>';
                }
            }
        }
    }
}
SetSMF('pause', false);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function processCommands()
{
    $commandsJson = $_POST['commands'];
    if (isset($commandsJson)) {
        $commandArray = json_decode($commandsJson);
        foreach ($commandArray as $command) {