Completed
Push — test ( fa17b2...617235 )
by Temitope
02:35
created
src/Database/DatabaseHandler.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
     {
42 42
     	$tableFields = $this->getColumnNames($this->model, $this->dbConnection);
43 43
     	
44
-    	$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields,$associative1DArray);
44
+    	$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields, $associative1DArray);
45 45
     	if (count($unexpectedFields) > 0) {
46
-    	    throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field");
46
+    	    throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
47 47
     	}
48 48
     	unset($tableFields[0]);
49 49
     	if (is_null($dbConn)) {
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
     private function  insertRecord($dbConn, $tableName, $associative1DArray) 
56 56
     {
57 57
     	$insertQuery = 'INSERT INTO '.$tableName;
58
-    	$TableValues = implode(',',array_keys($associative1DArray));
58
+    	$TableValues = implode(',', array_keys($associative1DArray));
59 59
     	foreach ($associative1DArray as $field => $value) {
60 60
     	    $FormValues[] = "'".trim(addslashes($value))."'";
61 61
     	}
62 62
     	$splittedTableValues = implode(',', $FormValues);
63
-    	$insertQuery.= ' ('.$TableValues.')';
64
-    	$insertQuery.= ' VALUES ('.$splittedTableValues.')';
63
+    	$insertQuery .= ' ('.$TableValues.')';
64
+    	$insertQuery .= ' VALUES ('.$splittedTableValues.')';
65 65
     	$executeQuery = $dbConn->exec($insertQuery);
66
-    	return $executeQuery ? : false;
66
+    	return $executeQuery ?: false;
67 67
     	
68 68
 	}
69 69
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
     	}
81 81
     	$updateSql = "UPDATE `$tableName` SET ";
82 82
     	unset($associative1DArray['id']);
83
-    	$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray);
83
+    	$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection), $associative1DArray);
84 84
     	
85 85
     	if (count($unexpectedFields) > 0) {
86 86
     		throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
87 87
     	}
88
-    	foreach($associative1DArray as $field => $value) {
88
+    	foreach ($associative1DArray as $field => $value) {
89 89
     	    $sql .= "`$field` = '$value'".",";
90 90
     	}
91 91
     	
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     	}
97 97
     	$stmt = $dbConn->prepare($updateSql);
98 98
     	$boolResponse = $stmt->execute();
99
-    	return $boolResponse ?  : false;
99
+    	return $boolResponse ?: false;
100 100
     }
101 101
     
102 102
   /**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
    	if (is_null($dbConn)) {
112 112
    	    $dbConn = new DatabaseConnection();
113 113
    	}
114
-   	$sql = $id  ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
114
+   	$sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
115 115
    	
116 116
    	try {
117 117
    	    $stmt = $dbConn->prepare($sql);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
    	}
124 124
    	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
125 125
    	
126
-   	foreach($results as $result) {
126
+   	foreach ($results as $result) {
127 127
    	    array_push($tableData, $result);
128 128
    	}
129 129
    	return $tableData;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
       
143 143
       $sql = 'DELETE FROM '.$tableName.' WHERE id = '.$id;
144 144
       $boolResponse = $dbConn->exec($sql);
145
-      return $boolResponse ? : false;
145
+      return $boolResponse ?: false;
146 146
   }
147 147
   
148 148
   /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
   {
156 156
       $unexpectedFields = [];
157 157
       foreach ($userSetterArray as $key => $val) {
158
-          if (!in_array($key,$tableColumn)) {
158
+          if (!in_array($key, $tableColumn)) {
159 159
               $unexpectedFields[] = $key;
160 160
           }
161 161
       }
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
     */
170 170
   public function prepareUpdateQuery($sql)
171 171
   {
172
-      $splittedQuery = explode(",",$sql);
172
+      $splittedQuery = explode(",", $sql);
173 173
       array_pop($splittedQuery);
174
-      $mergeData = implode(",",$splittedQuery);
174
+      $mergeData = implode(",", $splittedQuery);
175 175
       return $mergeData;
176 176
   }
177 177
   
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
           $statement->execute();
198 198
           $returnedRowNumbers = $statement->rowCount();
199 199
           
200
-          return $returnedRowNumbers  ? true : false;
200
+          return $returnedRowNumbers ? true : false;
201 201
       }
202 202
       throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array");
203 203
   }
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      $stmt->execute();
222 222
      $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
223 223
      
224
-     foreach($results as $result) {
224
+     foreach ($results as $result) {
225 225
          array_push($tableFields, $result['Field']);
226 226
      }
227 227
      return $tableFields;
Please login to merge, or discard this patch.