- 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:
Dave Mc Nicoll 2020-03-26 16:28:03 -04:00
parent 4b29232543
commit 6e84fc7195
2 changed files with 5 additions and 7 deletions

View File

@ -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) {

View File

@ -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;
}