mirror of
https://github.com/dg/dibi.git
synced 2025-02-24 02:43:09 +01:00
- DibiPostgreDriver: schema is case-sensitive
- DibiTranslator: %n modifier can construct [table] AS t statements
This commit is contained in:
parent
5ecfaf7ab1
commit
a5a1da19a7
@ -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', '>=');
|
||||
|
@ -41,6 +41,7 @@ class DibiFluent extends DibiObject
|
||||
/** @var array */
|
||||
public static $modifiers = array(
|
||||
'SELECT' => '%n',
|
||||
'FROM' => '%n',
|
||||
'IN' => '%l',
|
||||
'VALUES' => '%l',
|
||||
'SET' => '%a',
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user