1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 13:47:33 +02:00

- DibiConnection: fixed insert() with modifiers (thanks to Matej Kravjar)

This commit is contained in:
David Grudl
2009-08-13 12:20:03 +00:00
parent 8cc1d8b948
commit eeba6cfc91
2 changed files with 5 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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);