mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
- DibiConnection: fixed insert() with modifiers (thanks to Matej Kravjar)
This commit is contained in:
@@ -608,7 +608,7 @@ class DibiConnection extends DibiObject
|
|||||||
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
|
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
|
||||||
}
|
}
|
||||||
return $this->command()->insert()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -236,12 +236,13 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')';
|
return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')';
|
||||||
|
|
||||||
case 'n': // identifier names
|
case 'n': // key, key, ... identifier names
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
if (is_string($k)) {
|
if (is_string($k)) {
|
||||||
$vx[] = $this->delimite($k) . (empty($v) ? '' : ' AS ' . $v);
|
$vx[] = $this->delimite($pair[0]) . (empty($v) ? '' : ' AS ' . $v);
|
||||||
} else {
|
} else {
|
||||||
$vx[] = $this->delimite($v);
|
$vx[] = $this->delimite($pair[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return implode(', ', $vx);
|
return implode(', ', $vx);
|
||||||
|
Reference in New Issue
Block a user