- Added identifier escaping to match differents PDO drivers
This commit is contained in:
1 parent
def8decb4e
commit
3ff97f3bf0
8 files changed
+71
-30
No files matched your search
@@ -5,7 +5,13 @@ namespace Ulmus\Adapter;
|
||||
use Ulmus\Common\PdoObject;
|
||||
|
||||
interface AdapterInterface {
|
||||
public const IDENTIFIER_FIELD = 1;
|
||||
public const IDENTIFIER_TABLE = 2;
|
||||
public const IDENTIFIER_DATABASE = 3;
|
||||
public const IDENTIFIER_SCHEMA = 4;
|
||||
|
||||
public function connect() : PdoObject;
|
||||
public function buildDataSourceName() : string;
|
||||
public function setup(array $configuration) : void;
|
||||
public function escapeIdentifier(string $segment, int $type) : string;
|
||||
}
|
||||
@@ -185,4 +185,15 @@ class MsSQL implements AdapterInterface {
|
||||
$this->traceOn = $configuration['trace_on'];
|
||||
}
|
||||
}
|
||||
|
||||
public function escapeIdentifier(string $segment, int $type) : string
|
||||
{
|
||||
switch($type) {
|
||||
case static::IDENTIFIER_SCHEMA:
|
||||
case static::IDENTIFIER_DATABASE:
|
||||
case static::IDENTIFIER_TABLE:
|
||||
case static::IDENTIFIER_FIELD:
|
||||
return "[" . str_replace(["[", "]"], [ "[[", "]]" ], $segment) . "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,4 +123,15 @@ class MySQL implements AdapterInterface {
|
||||
$this->charset = $configuration['charset'];
|
||||
}
|
||||
}
|
||||
|
||||
public function escapeIdentifier(string $segment, int $type) : string
|
||||
{
|
||||
switch($type) {
|
||||
case static::IDENTIFIER_DATABASE:
|
||||
case static::IDENTIFIER_TABLE:
|
||||
case static::IDENTIFIER_FIELD:
|
||||
return "`" . str_replace("`", "``", $segment) . "`";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user