beginTransaction(); $sql = "INSERT INTO %queue% (date,prodid,tableid,tablecode,dailycode) VALUES(?,?,?,?,?)"; DbUtils::execSql($pdo, $sql, array($ordertime,$prodid,$tableid,$tablecode,$dailycode)); $pdo->commit(); DbUtils::log("Added product with id $prodid to mysql queue table"); return array("status" => "OK"); } else { $filename = dirname(__FILE__) . '/../db/' . QUEUE_FILE; try { $queueItems = array(); if (file_exists($filename)) { $queueItemsFileContent = file_get_contents($filename); $queueItems = json_decode($queueItemsFileContent,true); } $queueItems[] = array("date" => $ordertime,"prodid" => $prodid,"tableid" => $tableid, "tablecode" => $tablecode, "dailycode" => $dailycode); file_put_contents($filename, json_encode($queueItems)); DbUtils::log("Add product with id $prodid to file queue"); return array("status" => "OK"); } catch (Exception $ex) { return array("status" => "ERROR","msg" => $ex->getMessage()); } } } } if (isset($_GET["command"])) { $command = $_GET["command"]; $pdo = null; if (DB == "mysql") { $pdo = DbUtils::openDbAndReturnPdoStatic(); } switch ($command) { case "putintoqueue": $ret = Queue::putintoqueue($pdo,$_POST["prodid"],$_POST["tableid"],$_POST["tablecode"],$_POST["dailycode"]); echo json_encode($ret); break; default: break; } }