- Added identifier escaping to match differents PDO drivers

This commit is contained in:
Dave Mc Nicoll committed 2020-04-09 13:20:07 -04:00
1 parent def8decb4e
commit 3ff97f3bf0
8 files changed
+71 -30

No files matched your search

+4 -2
View File
@@ -3,6 +3,7 @@
namespace Ulmus\Common;
use Ulmus\Ulmus,
Ulmus\Adapter\AdapterInterface,
Ulmus\Annotation\Property\Field;
class EntityField
@@ -27,8 +28,9 @@ class EntityField
{
$name = $this->entityResolver->searchFieldAnnotation($this->name, new Field() )->name ?? $this->name;
#return $useAlias ? "{$this->alias}.`{$this->name}`" : "`{$this->name}`"; <-SQL
return $useAlias ? "{$this->alias}.\"{$name}\"" : "\"{$name}\"";
$name = ( $this->entityResolver->databaseAdapter() ?? Ulmus::$defaultAdapter )->adapter()->escapeIdentifier($name, AdapterInterface::IDENTIFIER_FIELD);
return $useAlias ? "{$this->alias}.$name" : $name;
}
public static function isScalarType($type) : bool
+9 -18
View File
@@ -15,14 +15,9 @@ class PdoObject extends PDO {
return $statement;
}
} catch (\PDOException $e) {
switch ( $e->getCode() ) {
case 42000:
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
default:
throw $e;
}
}
catch (\PDOException $e) {
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
}
}
@@ -31,14 +26,9 @@ class PdoObject extends PDO {
if (false !== ( $statement = $this->prepare($sql) )) {
return $this->execute($statement, $parameters, true);
}
} catch (\PDOException $e) {
switch ( $e->getCode() ) {
case 42000:
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
default:
throw $e;
}
}
catch (\PDOException $e) {
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
}
return null;
@@ -62,10 +52,11 @@ class PdoObject extends PDO {
else {
throw new \PDOException($statement->errorCode() . " - " . json_encode($statement->errorInfo()));
}
} catch (\PDOException $e) {
}
catch (\PDOException $e) {
$this->rollback();
throw $e;
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
}
return null;