Ejemplo n.º 1
0
<?php

$product = getRandomProduct($db);
Ejemplo n.º 2
0
<?php

$action = filter_input(INPUT_POST, 'ajaxAction', FILTER_SANITIZE_STRING);
if ($action) {
    switch ($action) {
        case 'getProductById':
            require_once APP_PATH . 'model/rateProduct.php';
            $userId = (int) filter_input(INPUT_POST, 'userId', FILTER_SANITIZE_STRING);
            $productId = (int) filter_input(INPUT_POST, 'productId', FILTER_SANITIZE_STRING);
            $need = (int) filter_input(INPUT_POST, 'need', FILTER_SANITIZE_STRING);
            $noNeed = (int) filter_input(INPUT_POST, 'no_need', FILTER_SANITIZE_STRING);
            $rate = rateProduct($userId, $productId, $need, $noNeed, $db);
            require_once APP_PATH . 'model/getRandomProduct.php';
            if ($productId) {
                print json_encode(getRandomProduct($db), JSON_FORCE_OBJECT);
                exit;
            } else {
                die('ERROR');
            }
            break;
        default:
            die('ERROR');
            break;
    }
} else {
    die('ERROR');
}