Esempio n. 1
0
$items = $_POST['items'];
//$items = json_decode($items,true);
if ($option == 'add') {
    addToCart($items, $project);
    echo "success";
} else {
    if ($option == 'remove') {
        removeFromCart($items, $project);
        //print_r($_SESSION[$project]['idList']);
        echo "success";
    } else {
        if ($option == 'show') {
            echo json_encode($_SESSION[$project]['idList']);
        } else {
            if ($option = 'removeAll') {
                removeAll($project);
                echo "success";
            }
        }
    }
}
function addToCart($items, $project)
{
    foreach ($items as $k => $v) {
        $_SESSION[$project]['idList'][$k] = $v;
    }
}
function removeFromCart($items, $project)
{
    foreach ($items as $k => $v) {
        unset($_SESSION[$project]['idList'][$k]);
 private function procesarCategorias($connection)
 {
     try {
         //las categorias que estan en la bd no requieren modificacion
         //Collection<Integer> altas = new ArrayList($this->categorias);
         $altas = new ArrayCollection($this->categorias);
         if (is_null($this->categorias_bd)) {
             $this->categorias_bd = new ArrayCollection();
         }
         //Collection<Integer> bajas = new ArrayList($this->categorias_bd);
         $bajas = new ArrayCollection($this->categorias_bd);
         //borro las categorias comunes y quedan solo las que tengo que agregar
         $altas . removeAll($this->categorias_bd);
         $this->AgregarCategorias($connection, $altas);
         //borro las categorias comunes y quedan las que debo eliminar
         $bajas . removeAll($this->categorias);
         $this->BorrarCategorias($connection, bajas);
     } catch (\PDOException $e) {
         throw $e;
     }
 }