Пример #1
0
if (empty($updata["id"])) {
    errormsg("The 'projectID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "UPDATE projects SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= $key . " = :" . $key;
            $ct++;
        }
    }
    $sql .= " WHERE id = :id";
    $st = $db->prepare($sql);
    foreach ($updata as $key => &$value) {
        if ($value != "") {
            $st->bindParam(":" . $key, $value);
        }
    }
    $st->execute();
    $newproject = $dbh->getProjects($updata["id"]);
} catch (PDOException $e) {
    errormsg($e->getMessage());
}
exitjson(array("project" => $newproject[0]));
Пример #2
0
    }
    $sql .= ") VALUES (";
    $ct = 0;
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
            $sql .= ":" . $key;
            $ct++;
        }
    }
    $sql .= ")";
    $st = $db->prepare($sql);
    foreach ($updata as $key => &$value) {
        if ($value != "") {
            $st->bindParam(":" . $key, $value);
        }
    }
    $st->execute();
    $st = $db->prepare("SELECT LAST_INSERT_ID()");
    $st->execute();
    $lastid = $st->fetch();
    $newproject = $dbh->getProjects($lastid[0]);
    $sql = "INSERT INTO userslink (userID, projectID) VALUES (:userID, :projectID)";
    $st = $db->prepare($sql);
    $st->execute(array(":userID" => $updata["projectCreator"], ":projectID" => $lastid[0]));
} catch (PDOException $e) {
    errormsg($e->getMessage());
}
exitjson(array("newproject" => $newproject[0]));
Пример #3
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = $_SESSION["user"];
$dbh = new PDB();
$db = $dbh->db;
$projectIDs = $dbh->getValidProjects($userID);
$projectID = param($_GET, 'projectID', $projectIDs);
$projects = $dbh->getProjects($projectID);
exitjson(array("projects" => $projects));
/*
if($st->rowCount() == 0){
	errormsg("Username or password incorrect.");
};
*/