Merge branch 'bugfix/warehouse-price-handling' into 'master'

fixed mysql query for history

See merge request fronk/thetool!511
This commit is contained in:
Luca Haid
2024-07-25 06:22:10 +00:00

View File

@@ -24,9 +24,8 @@ class WarehouseHistoryModel {
public static function create($data) {
$FronkDB = FronkDB::singleton();
$db = $FronkDB->link;
$sql = /** @lang text */ "INSERT INTO `WarehouseHistory` (`table`, `row_id`, `key`, `old_value`, `new_value`, `note`, `user_id`, `create`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $db->prepare($sql);
$stmt->execute([
$dataArr = [
$data["table"],
$data["row_id"],
$data["key"],
@@ -35,9 +34,16 @@ class WarehouseHistoryModel {
$data["note"],
$data["user_id"],
$data["create"]
]);
];
return $stmt->insert_id;
$sqlValueStr = "(" . implode(", ", array_map(function ($item) use ($db) {
return "'" . $db->real_escape_string($item) . "'";
}, $dataArr)) . ")";
$sql = /** @lang text */ "INSERT INTO `WarehouseHistory` (`table`, `row_id`, `key`, `old_value`, `new_value`, `note`, `user_id`, `create`) VALUES $sqlValueStr";
$db->query($sql) or die($db->error);
return $db->insert_id;
}
/**
* Retrieves an array of WarehouseHistoryModel objects by row ID.