1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 01:24:06 +02:00

rewritten dibi::IDENTIFIER escaping; added support for [table.*]

This commit is contained in:
David Grudl
2010-05-19 14:53:19 +02:00
parent 27930611de
commit bec559448c
11 changed files with 20 additions and 37 deletions

View File

@@ -242,25 +242,19 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
case dibi::IDENTIFIER:
switch ($this->connection->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
$value = str_replace('`', '``', $value);
return '`' . str_replace('.', '`.`', $value) . '`';
return '`' . str_replace('`', '``', $value) . '`';
case 'pgsql':
$a = strrpos($value, '.');
if ($a === FALSE) {
return '"' . str_replace('"', '""', $value) . '"';
} else {
return substr($value, 0, $a) . '."' . str_replace('"', '""', substr($value, $a + 1)) . '"';
}
return '"' . str_replace('"', '""', $value) . '"';
case 'sqlite':
case 'sqlite2':
$value = strtr($value, '[]', ' ');
return '[' . strtr($value, '[]', ' ') . ']';
case 'odbc':
case 'oci': // TODO: not tested
case 'mssql':
$value = str_replace(array('[', ']'), array('[[', ']]'), $value);
return '[' . str_replace('.', '].[', $value) . ']';
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
default:
return $value;