handled case domain not found, also in findbyid
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
1052e00cf5
commit
087db2b2a9
|
@ -47,9 +47,9 @@ class DomainRepository
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
*
|
||||||
* @return \App\Entity\Domain
|
* @return false
|
||||||
*/
|
*/
|
||||||
public function findByID(int $id): Domain
|
public function findByID(int $id): bool|Domain
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT id, name, panel_id, a, aaaa
|
SELECT id, name, panel_id, a, aaaa
|
||||||
|
@ -60,22 +60,23 @@ class DomainRepository
|
||||||
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
||||||
$statement->bindParam(param: ':id', var: $id);
|
$statement->bindParam(param: ':id', var: $id);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
$result = $statement->fetch(mode: PDO::FETCH_ASSOC);
|
if ($result = $statement->fetch(mode: PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
return new Domain(name: $result['name'], panelID: $result['panel_id'], a: $result['a'], aaaa: $result['aaaa']);
|
return new Domain(name: $result['name'], panelID: $result['panel_id'], a: $result['a'], aaaa: $result['aaaa']);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
exit($e->getMessage());
|
exit($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $name
|
* @param String $name
|
||||||
*
|
*
|
||||||
* @return \App\Entity\Domain
|
* @return \App\Entity\Domain|bool
|
||||||
*/
|
*/
|
||||||
public function findByName(string $name): Domain
|
public function findByName(string $name): Domain|bool
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT id, name, panel_id, a, aaaa
|
SELECT id, name, panel_id, a, aaaa
|
||||||
|
@ -86,9 +87,13 @@ class DomainRepository
|
||||||
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
||||||
$statement->bindParam(param: ':name', var: $name);
|
$statement->bindParam(param: ':name', var: $name);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
$result = $statement->fetch(mode: PDO::FETCH_ASSOC);
|
if ($result = $statement->fetch(mode: PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
return new Domain(name: $result['name'], panelID: $result['panel_id'], a: $result['a'], aaaa: $result['aaaa']);
|
return new Domain(name: $result['name'], panelID: $result['panel_id'], a: $result['a'], aaaa: $result['aaaa']);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
exit($e->getMessage());
|
exit($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue