- 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
|
||||
{
|
||||
try{
|
||||
return $this->fieldList($fieldKey)[$name];
|
||||
return $this->fieldList($fieldKey)[$name] ?? null;
|
||||
}
|
||||
catch(\Throwable $e) {
|
||||
if ( $throwException) {
|
||||
|
|
|
@ -8,8 +8,6 @@ use PDO,
|
|||
class PdoObject extends PDO {
|
||||
|
||||
public function select(string $sql, array $parameters = []): PDOStatement {
|
||||
# var_dump($sql, $parameters); die();
|
||||
|
||||
try {
|
||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||
$statement = $this->execute($statement, $parameters, false);
|
||||
|
@ -23,8 +21,6 @@ class PdoObject extends PDO {
|
|||
}
|
||||
|
||||
public function runQuery(string $sql, array $parameters = []): ? PDOStatement {
|
||||
# dump($sql, $parameters); return null;
|
||||
|
||||
try {
|
||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||
return $this->execute($statement, $parameters, true);
|
||||
|
@ -50,11 +46,13 @@ class PdoObject extends PDO {
|
|||
}
|
||||
|
||||
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) {
|
||||
$this->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue