Exemple #1
0
    } catch (PDOException $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
        $app->response()->write('xxx');
    }
});
$app->put('/uom/:comp/:id', $authKey, function ($comp, $id) use($app) {
    try {
        $request_params = array();
        $request_params = $_REQUEST;
        if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
            $app = \Slim\Slim::getInstance();
            parse_str($app->request()->getBody(), $request_params);
        }
        $requiredfields = reqParams::reqUomInsert();
        requiredFields($requiredfields);
        $sql = "UPDATE il_uom set il_uom_id=:uom_id, il_uom_desc=:uom_desc where idil_uom=:uom_iid and il_company_acc='" . $comp . "'";
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->bindParam("uom_iid", $id);
        $stmt->bindParam("uom_id", $request_params['uom_id']);
        $stmt->bindParam("uom_desc", $request_params['uom_desc']);
        $stmt->execute();
        $data = $db->lastInsertId();
        $db = null;
        $response = $app->response();
        $response->write(json_encode(response($data, 'Update UOM Success', true)));
    } catch (PDOException $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
Exemple #2
0
            $db = new Database();
            $db->query("INSERT INTO categories VALUES ('',:name,:description)");
            $db->bind(":name", strip_tags($_POST['newCat'], ''));
            $db->bind(":description", $b);
            $db->execute();
            $db->query("SELECT id FROM categories ORDER BY id DESC LIMIT 1");
            $result = $db->single();
            $data['category_id'] = $result->id;
        } else {
            $data['category_id'] = strip_tags($_POST['category'], '');
        }
        $data['user_id'] = $_SESSION['user_id'];
        $data['last_activity'] = date("Y-m-d H:i:s");
        $data['body'] = strip_tags($_POST['body'], '<iframe><br>');
        $required = array("title", "category_id");
        if (requiredFields($required, $data)) {
            if ($user->createTopic($data)) {
                add_notification($_SESSION['user_id'], "asked a question", getlastid('topics'), 0, followers_id($_SESSION['user_id']));
                echo '<div class="al alert alert-success" style="text-align:center">Successfully posted your query</div>
	 <script>reload();</script>';
            } else {
                echo '<div class="al alert alert-danger" style="text-align:center">Couldn\'t Upload. Please try after some time </div>';
            }
        } else {
            echo '<div class="al alert alert-warning" style="text-align:center">Please fill all the required fields</div>';
        }
    }
    echo $template;
} else {
    redirect("index.php");
}