//这会将插入到db。中的两个表中。
$app->post('/create_order', 'authenticate', function() use($app) {
// check for required params
verifyRequiredParams(array('oder_data'));
global $user_id;
$oder_data = $app->request->post('oder_data');
$db = new DbHandler();
$id_client=$user_id;
$response = array();
//parsing a json array
$json_a=json_decode($oder_data,true);
if (!$json_a=="") {
$order_type=$json_a["order_type"];
$id_reservation=$json_a["id_reservation"];
$id_order = $db->createOrder($id_client, $order_type, $id_reservation);
$hh=$json_a['data'];
foreach($json_a['data'] as $p)
{
$id_dish=$p['id_dish'];
$amount=$p['amount'];
$description=$p['description'];
$note=$p['note'];
$result = $db->insert_order_items($id_order, $id_dish, $amount, $description, $note);
}
return true;