我在购物车数据库中有 4 条记录。我得到了结果:4444。如何将结果改为 1234?
看法:
$i = 0;
foreach($carts AS $cart) {
$x = $i+1;
echo $x;
}
控制器:
function confirm() {
$orders = $this->data;
$sessionId = $this->passedArgs['ct_session_id'];
$this->set('data', $sessionId );
$carts = $this->Cart->find(
'all',
array('conditions' => array('Cart.ct_session_id' => $sessionId), 'recursive' => 1)
);
$this->set(compact('carts', 'orders'));
}