38471-vm/replace_inserts.php
2026-02-25 09:58:14 +00:00

14 lines
856 B
PHP

<?php
$content = file_get_contents('index.php');
$tables = ['users', 'invoices', 'lpos', 'purchases', 'quotations', 'expenses', 'payments', 'purchase_payments', 'pos_transactions', 'customers', 'suppliers', 'stock_items', 'pos_held_carts', 'loyalty_transactions', 'purchase_returns', 'sales_returns'];
foreach ($tables as $t) {
// Regex to match: INSERT INTO table (...) VALUES (...)
// and replace with INSERT INTO table (outlet_id, ...) VALUES (current_outlet_id(), ...)
// Note: since this is PDO prepare, we can't just inject current_outlet_id() directly into VALUES if it's parametrized, but we CAN inject the value if we just use a session variable call directly in SQL, or `?` and prepend the param.
// Wait, simpler: "INSERT INTO $t (outlet_id, " . "(current_outlet_id())" is safe enough?
// Let's look at a simpler regex.
}