function createOrder($data)
{
    $dbcon = DBconnect();
    $stmt = $dbcon->prepare("INSERT into tbl_orders (orderFName, orderLName, orderEmail, orderType, orderPlaceDateTime, orderDueDate, paid, baked, readyForPickup, pickedUp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("ssssssssss", $data['orderFName'], $data['orderLName'], $data['orderEmail'], $data['orderType'], $data['orderPlaceDateTime'], $data['orderDueDate'], $data['paid'], $data['baked'], $data['readyForPickup'], $data['pickedUp']);
    $stmt->execute();
    $id = $dbcon->insert_id;
    DBdisconnect($dbcon);
    echo $id;
}
Example #2
0
                    DBexec($db_handler, $sql);
                    logEvent($db_handler, TYPE_OUT_ON, "Output {$out_id} turned ON by a schedule");
                    logMessage("IrrighinoTask - OUT_ID {$out_id} turned ON and event logged in the DB");
                } else {
                    logEvent($db_handler, TYPE_ERROR, "Unable to turn ON output {$out_id}");
                    logMessage("IrrighinoTask - Error while calling Arduino to turn ON OUT_ID {$out_id}, response: {$response}");
                }
            }
        } else {
            logMessage("IrrighinoTask - No events found for this OUT_ID");
            // if the output is ON, turn it OFF
            if ($out_status == STATUS_ON) {
                $response = callArduino("off/{$out_id}");
                if (strpos($response, "OK") !== false) {
                    $sql = "UPDATE OUTPUTS SET OUT_STATUS = " . STATUS_OFF . " WHERE OUT_ID = {$out_id}";
                    DBexec($db_handler, $sql);
                    logEvent($db_handler, TYPE_OUT_OFF, "Output {$out_id} turned OFF by a schedule");
                    logMessage("IrrighinoTask - OUT_ID {$out_id} turned OFF and event logged in the DB");
                } else {
                    logEvent($db_handler, TYPE_ERROR, "Unable to turn OFF output {$out_id}");
                    logMessage("IrrighinoTask - Error while calling Arduino to turn ON OUT_ID {$out_id}, response: {$response}");
                }
            }
        }
    }
    // the query command returned false (= error)
} else {
    logMessage("IrrighinoTask - Error while querying the DB: " . $db_handler->errorInfo()[2]);
}
DBdisconnect();
logMessage("IrrighinoTask - Completed");