query("SHOW COLUMNS FROM branches LIKE 'avatar'"); if (\$stmt2->rowCount() === 0) { \$pdo->exec("ALTER TABLE branches ADD COLUMN avatar varchar(255) DEFAULT NULL"); } @file_put_contents(\$flagFile, '1'); S1; $r1 = <<query("SHOW COLUMNS FROM branches LIKE 'avatar'"); if (\$stmt2->rowCount() === 0) { \$pdo->exec("ALTER TABLE branches ADD COLUMN avatar varchar(255) DEFAULT NULL"); } \$stmt3 = \pdo->query("SHOW COLUMNS FROM sales_orders LIKE 'customer_id'"); if (\$stmt3->rowCount() === 0) { \$pdo->exec("ALTER TABLE sales_orders ADD COLUMN customer_id int(10) unsigned DEFAULT NULL"); } \$stmt4 = \pdo->query("SHOW COLUMNS FROM sales_orders LIKE 'payment_status'"); if (\$stmt4->rowCount() === 0) { \$pdo->exec("ALTER TABLE sales_orders ADD COLUMN payment_status varchar(20) NOT NULL DEFAULT 'paid'"); } @file_put_contents(\$flagFile, '1'); R1; $c = str_replace($s1, $r1, $c); // add to ensure_sales_table() $s2 = <<bindValue(':customer_name', $data['customer_name']); $stmt->bindValue(':payment_method', $data['payment_method']); S4; $r4 = <<bindValue(':customer_id', $data['customer_id'] ?? null, PDO::PARAM_INT); $stmt->bindValue(':customer_name', $data['customer_name']); $stmt->bindValue(':payment_method', $data['payment_method']); $stmt->bindValue(':payment_status', $data['payment_status'] ?? 'paid'); R4; $c = str_replace($s4, $r4, $c); file_put_contents('includes/app.php', $c); echo "Patched includes/app.php\n";