1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 21:58:10 +02:00

- added connection directive 'substitutes'

- better ArrayObject handling in DibiTranslator
This commit is contained in:
David Grudl
2009-02-25 20:10:17 +00:00
parent 14b731e002
commit d2f1beba57
2 changed files with 14 additions and 1 deletions

View File

@@ -98,6 +98,12 @@ class DibiConnection extends DibiObject
$this->setProfiler(new $class);
}
if (!empty($config['substitutes'])) {
foreach ($config['substitutes'] as $key => $value) {
dibi::addSubst($key, $value);
}
}
if (empty($config['lazy'])) {
$this->connect();
}

View File

@@ -142,6 +142,10 @@ final class DibiTranslator extends DibiObject
continue;
}
if ($arg instanceof ArrayObject) {
$arg = (array) $arg;
}
if (is_array($arg)) {
if (is_string(key($arg))) {
// associative array -> autoselect between SET or VALUES & LIST
@@ -196,8 +200,11 @@ final class DibiTranslator extends DibiObject
public function formatValue($value, $modifier)
{
// array processing (with or without modifier)
if (is_array($value) || $value instanceof ArrayObject) {
if ($value instanceof ArrayObject) {
$value = (array) $value;
}
if (is_array($value)) {
$vx = $kx = array();
switch ($modifier) {
case 'and':