내가 2 컨트롤러가 : 라이브러리 카트의 내용을 보여 모두에서CodeIgniter의 캐시 컨트롤러 문제
cart/
cart/buy
을
<tbody>
<?php foreach($this->cart->contents() as $items): ?>
<tr>
<td><?php echo $items['name'] ?></td>
<td>$ <?php echo $this->cart->format_number($items['price']); ?></td>
<td><?php echo $items['qty'] ?></td>
<td>$ <?php echo $this->cart->format_number($items['subtotal']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
내 문제 컨트롤러 내가 추가 할 때 캐시에 남아 살이다 카트에 첫 번째 항목. 내 말은, 컨트롤러 카트/에는 5 개의 항목과 컨트롤러가 있습니다. 장바구니/구매에는 1 개의 항목이 있습니다. 나는이 부분을 해결할 수 있었다
모든 항목을 볼 수 Ctrl + F5를 눌러야 :
function buy()
{
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
if($this->cart->contents())
{
$this->load->view('web/products/buy_view');
}
else
{
redirect('cart');
}
}
을하지만, 참조, 나는 데이터가 장바구니에있는 경우 알고 다른 페이지로 리디렉션 할 카트가 비어 있으면.
분명히 경우 ($ this-> cart->의 내용은()) 예를 들어 카트 장바구니에 카트/ 채워하지만 빈 할 수있는, "캐시에 남아"/ 때까지 구매 Ctrl F5를 누르면 여전히 오류가 발생했습니다.
이 문제를 해결할 방법이 있습니까? 아니면 내가 잘못하고있는 것이 있습니까?
p.d. 카트 컨트롤러 내 추가 방법 :
이function add_item()
{
if($this->cart_model->validate_add_item() == TRUE)
{
redirect('cart');
}
}
내 추가 방법 카트 모델 :
function validate_add_item()
{
$id = $this->input->post('producto_id');
$cantidad = $this->input->post('cantidad');
$this->db->select('vNombre, dPrecio');
$this->db->where('iIdProducto', $id);
$query = $this->db->get('product', 1);
if($query->num_rows > 0)
{
foreach ($query->result() as $row)
{
$data = array(
'id' => $id,
'qty'=> $cantidad,
'price' => $row->dPrecio,
'name' => $row->vNombre
);
$this->cart->insert($data);
return TRUE;
}
}
else
{
return FALSE;
}
}
을 : add_item()를 – csotelo
좋아, 많은 도움이 내 편집 포스트 – csotelo
를 볼 불행하게도 내가 할 수있는 ' 문제는 보지만 다른 사람에게 도움이 될 것입니다. 나는 당신에게 upvote를주고 당신에게 행운을 빌어 줄께. –