- Fixed a bug while retrieving a non-existing field (from a table which has a field not included within your entity)
This commit is contained in:
parent
4b29232543
commit
6e84fc7195
|
@ -39,7 +39,7 @@ class EntityResolver {
|
||||||
public function field($name, $fieldKey = self::KEY_ENTITY_NAME, $throwException = true) : ? array
|
public function field($name, $fieldKey = self::KEY_ENTITY_NAME, $throwException = true) : ? array
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
return $this->fieldList($fieldKey)[$name];
|
return $this->fieldList($fieldKey)[$name] ?? null;
|
||||||
}
|
}
|
||||||
catch(\Throwable $e) {
|
catch(\Throwable $e) {
|
||||||
if ( $throwException) {
|
if ( $throwException) {
|
||||||
|
|
|
@ -8,8 +8,6 @@ use PDO,
|
||||||
class PdoObject extends PDO {
|
class PdoObject extends PDO {
|
||||||
|
|
||||||
public function select(string $sql, array $parameters = []): PDOStatement {
|
public function select(string $sql, array $parameters = []): PDOStatement {
|
||||||
# var_dump($sql, $parameters); die();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||||
$statement = $this->execute($statement, $parameters, false);
|
$statement = $this->execute($statement, $parameters, false);
|
||||||
|
@ -23,8 +21,6 @@ class PdoObject extends PDO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runQuery(string $sql, array $parameters = []): ? PDOStatement {
|
public function runQuery(string $sql, array $parameters = []): ? PDOStatement {
|
||||||
# dump($sql, $parameters); return null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||||
return $this->execute($statement, $parameters, true);
|
return $this->execute($statement, $parameters, true);
|
||||||
|
@ -50,11 +46,13 @@ class PdoObject extends PDO {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $statement;
|
return $statement;
|
||||||
} else {
|
}
|
||||||
throw new PDOException('Could not begin transaction or given statement is invalid.');
|
else {
|
||||||
|
throw new \PDOException($statement->errorCode() . " - " . json_encode($statement->errorInfo()));
|
||||||
}
|
}
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
$this->rollback();
|
$this->rollback();
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue