diff --git a/dibi/libs/DibiConnection.php b/dibi/libs/DibiConnection.php index 92f4c130..d2711bae 100644 --- a/dibi/libs/DibiConnection.php +++ b/dibi/libs/DibiConnection.php @@ -608,7 +608,7 @@ class DibiConnection extends DibiObject throw new InvalidArgumentException('Arguments must be array or ArrayObject.'); } return $this->command()->insert() - ->into('%n', $table, '(%n)', array_keys($args))->values('%l', array_values($args)); + ->into('%n', $table, '(%n)', array_keys($args))->values('%l', $args); } diff --git a/dibi/libs/DibiTranslator.php b/dibi/libs/DibiTranslator.php index f5219f02..bdb5148e 100644 --- a/dibi/libs/DibiTranslator.php +++ b/dibi/libs/DibiTranslator.php @@ -236,12 +236,13 @@ final class DibiTranslator extends DibiObject } return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')'; - case 'n': // identifier names + case 'n': // key, key, ... identifier names foreach ($value as $k => $v) { + $pair = explode('%', $k, 2); // split into identifier & modifier if (is_string($k)) { - $vx[] = $this->delimite($k) . (empty($v) ? '' : ' AS ' . $v); + $vx[] = $this->delimite($pair[0]) . (empty($v) ? '' : ' AS ' . $v); } else { - $vx[] = $this->delimite($v); + $vx[] = $this->delimite($pair[0]); } } return implode(', ', $vx);