From 0cd24b7ab2a3570d59240fc77bf7fe7befe2c579 Mon Sep 17 00:00:00 2001 From: Leander Date: Wed, 22 Mar 2017 14:34:26 +0100 Subject: [PATCH] new error numbering convention --- Config.txt | 6 ++++++ Database.php | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Config.txt diff --git a/Config.txt b/Config.txt new file mode 100644 index 0000000..6569ad9 --- /dev/null +++ b/Config.txt @@ -0,0 +1,6 @@ +=== GLOBAL CONFIGURATIONS === + +== Error Codes === + += Database.php = +10101 - SQL request did not give a result diff --git a/Database.php b/Database.php index b5a372f..5219a8e 100644 --- a/Database.php +++ b/Database.php @@ -22,11 +22,18 @@ class Database $result = pg_query($this->db, $sql); } if(!$result) { - echo json_encode(array("error"=>1)); - exit; + $error = 10101; } - $arr = pg_fetch_all($result); - return $arr; + if(!$error) { + $data = pg_fetch_all($result); + } else { + $data = null; + } + $this->create_response($data, $error); + } + + function create_response($data, $error = null){ + //TODO } }