Esempio n. 1
0
function createProject()
{
    $account = getAccount();
    $projdue = tryRetrieve($_POST, 'projDue');
    $projtime = strtotime($projdue);
    $duedate = sqlsafe(date("Y-m-d H:i:s", $projtime));
    $title = sqlSafe(tryRetrieve($_POST, 'projName'));
    //$notes = sqlSafe(tryRetrieve($_POST, 'projNotes'));
    $query = "INSERT INTO projects (account_id, duedate, title) VALUES ({$account}, {$duedate}, {$title})";
    if (writeQuery($query)) {
        $id = getInsertID();
        //Now give the project a hash
        $hash = sqlSafe(hash('adler32', $id));
        $query = "UPDATE projects SET hash={$hash} where id='{$id}'";
        if (writeQuery($query)) {
            $_SESSION['project'] = $id;
            return getProjectInfo();
        }
    }
    return null;
}
Esempio n. 2
0
function insertRecord($table, $fields, $autoIncrement)
{
    $columns = "";
    $values = "";
    $query = "";
    foreach ($fields as $column => $value) {
        if ($columns !== "") {
            $columns .= ", ";
        }
        if ($values !== "") {
            $values .= ", ";
        }
        $columns .= $column;
        $values .= $value;
    }
    $query = "INSERT INTO {$table} ({$columns}) VALUES ({$values})";
    executeQuery($query);
    if ($autoIncrement) {
        return getInsertID();
    } else {
        return -1;
    }
}