fix: add unicode flag to named param regex for ö/ä chars

Column name yhteyshenkilö contains ö which \w doesn't match
without the /u flag. This caused SQL syntax errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 16:26:44 +02:00
parent 8a630508f4
commit b074b7db28

2
db.php
View File

@@ -35,7 +35,7 @@ function _dbRun(string $sql, array $params = []): mysqli_stmt {
// Muunna nimetyt parametrit (:name) positiivisiksi (?) // Muunna nimetyt parametrit (:name) positiivisiksi (?)
if (!empty($params) && !array_is_list($params)) { if (!empty($params) && !array_is_list($params)) {
$ordered = []; $ordered = [];
$sql = preg_replace_callback('/:(\w+)/', function($m) use ($params, &$ordered) { $sql = preg_replace_callback('/:(\w+)/u', function($m) use ($params, &$ordered) {
$key = $m[1]; $key = $m[1];
$ordered[] = array_key_exists($key, $params) ? $params[$key] : null; $ordered[] = array_key_exists($key, $params) ? $params[$key] : null;
return '?'; return '?';