can you help me , insert multi row now work
I var_dump($max); , this render 2 row but them I button submit , saveRows() not insert array , that only one worth taking .
array(2) {
[0]=>
array(2) {
["productid"]=>
string(1) "3"
["qty"]=>
int(1)
}
[1]=>
array(2) {
["productid"]=>
string(1) "1"
["qty"]=>
int(1)
}
}
public function saveRows() {
$max = count($_SESSION['cart']);
for ($i = 0; $i < $max; $i++) {
$orderid = Yii::app()->db->getLastInsertID();
$detailid = Yii::app()->db->getLastInsertID();
$product_id = $_SESSION['cart'][$i]['productid'];
$quantity = $_SESSION['cart'][$i]['qty'];
$price = $_POST['orderprice'];
$result = ("insert into order_detail values($detailid,$orderid,$product_id,$quantity,$price)");
}
$command = Yii::app()->db->createCommand($result);
if ($command->execute()) :
return TRUE;
endif;
return FALSE;
}