Beispiel #1
0
if (empty($updata["id"])) {
    errormsg("The 'clientID' is required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
try {
    $ct = 0;
    $sql = "UPDATE clients 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();
    $newclient = $dbh->getClient($user, $updata["id"]);
} catch (PDOException $e) {
    errormsg($e->getMessage());
}
exitjson(array("client" => $newclient));
Beispiel #2
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;
$clientID = param($_GET, 'clientID', '');
if ($clientID == '') {
    $clients = $dbh->getClients($userID);
} else {
    $clients = $dbh->getClient($userID, $clientID);
}
exitjson(array("clients" => $clients));