diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index 3ef1630..4659563 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -104,7 +104,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver } if (isset($config['schema'])) { - $this->query('SET search_path TO ' . $config['schema']); + $this->query('SET search_path TO "' . $config['schema'] . '"'); } $this->escMethod = version_compare(PHP_VERSION , '5.2.0', '>='); diff --git a/dibi/libs/DibiFluent.php b/dibi/libs/DibiFluent.php index d5fa606..e627604 100644 --- a/dibi/libs/DibiFluent.php +++ b/dibi/libs/DibiFluent.php @@ -41,6 +41,7 @@ class DibiFluent extends DibiObject /** @var array */ public static $modifiers = array( 'SELECT' => '%n', + 'FROM' => '%n', 'IN' => '%l', 'VALUES' => '%l', 'SET' => '%a', diff --git a/dibi/libs/DibiTableX.php b/dibi/libs/DibiTableX.php index ce44192..d0051fe 100644 --- a/dibi/libs/DibiTableX.php +++ b/dibi/libs/DibiTableX.php @@ -124,7 +124,7 @@ abstract class DibiTableX extends DibiObject if ($this->primary === NULL) { $this->primary = str_replace( array('%p', '%s'), - array($this->name, trim($this->name, 's')), // the simplest inflector in the world :-)) + array($this->name, rtrim($this->name, 's')), // the simplest inflector in the world :-)) self::$primaryMask ); } @@ -179,7 +179,7 @@ abstract class DibiTableX extends DibiObject /** * Inserts or updates rows in a table. * @param array|object - * @return int (new) primary key + * @return void */ public function insertOrUpdate($data) { diff --git a/dibi/libs/DibiTranslator.php b/dibi/libs/DibiTranslator.php index fcada26..8aac22b 100644 --- a/dibi/libs/DibiTranslator.php +++ b/dibi/libs/DibiTranslator.php @@ -227,6 +227,17 @@ final class DibiTranslator extends DibiObject } return implode($operator, $vx); + case 'n': // identifier names + foreach ($value as $k => $v) { + if (is_string($k)) { + $vx[] = $this->delimite($k) . ' AS ' . $v; + } else { + $vx[] = $this->delimite($v); + } + } + return implode(', ', $vx); + + case 'a': // key=val, key=val, ... foreach ($value as $k => $v) { $pair = explode('%', $k, 2); // split into identifier & modifier