fixed mysql query for history
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user