here is my scheme i want to insert multiple orderdetail against 1 order in 1 time.
order (id,customer_id,phone,address,total,created_date) orderdetails(id,order_id,inventory_id,quantity,amount,created_date)
thats how i am doing but it is giving me error....
try {
$manager = new TxManager();
// Request a transaction
$transaction = $manager->get();
$order=new order();
$order->setTransaction($transaction);
// assign values to properties
$order->id="160912-170200-9876";
$order->customer_id=26535;
$order->phone="2443434";
$order->total=219.00;
if ($order->save() == false) {
$transaction->rollback("Cannot save robot part");
echo json_encode(array('status'=>'501','message'=>"error in saving order sum"));
}
$orderdetails=new orderdetails();
$orderdetails->setTransaction($transaction);
//assign values
$orderdetails->inventory_id =2;
$orderdetails->quantity=1;
$orderdetails->amount=199.00;
$orderdetails->order_id="160912-170200-9876";
if ($orderdetails->save() == false) {
$transaction->rollback("Cannot save robot part");
}
$transaction->commit();
echo json_encode(array('status'=>'1','message'=>"success"));
}
catch (TxFailed $e) {
echo json_encode(array('status'=>'501','message'=>'orders failed because '.$e->getMessage()));
}