mirror of
https://github.com/dg/dibi.git
synced 2025-02-24 10:53:17 +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'])) {
|
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', '>=');
|
$this->escMethod = version_compare(PHP_VERSION , '5.2.0', '>=');
|
||||||
|
@ -41,6 +41,7 @@ class DibiFluent extends DibiObject
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
public static $modifiers = array(
|
public static $modifiers = array(
|
||||||
'SELECT' => '%n',
|
'SELECT' => '%n',
|
||||||
|
'FROM' => '%n',
|
||||||
'IN' => '%l',
|
'IN' => '%l',
|
||||||
'VALUES' => '%l',
|
'VALUES' => '%l',
|
||||||
'SET' => '%a',
|
'SET' => '%a',
|
||||||
|
@ -124,7 +124,7 @@ abstract class DibiTableX extends DibiObject
|
|||||||
if ($this->primary === NULL) {
|
if ($this->primary === NULL) {
|
||||||
$this->primary = str_replace(
|
$this->primary = str_replace(
|
||||||
array('%p', '%s'),
|
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
|
self::$primaryMask
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ abstract class DibiTableX extends DibiObject
|
|||||||
/**
|
/**
|
||||||
* Inserts or updates rows in a table.
|
* Inserts or updates rows in a table.
|
||||||
* @param array|object
|
* @param array|object
|
||||||
* @return int (new) primary key
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function insertOrUpdate($data)
|
public function insertOrUpdate($data)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +227,17 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
return implode($operator, $vx);
|
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, ...
|
case 'a': // key=val, key=val, ...
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
|
Loading…
x
Reference in New Issue
Block a user