Completed
Push — master ( a847da...ede37a )
by Federico
03:15
created
dist/jate/modules/Query/Query.php 1 patch
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
       $this->currentConnection = null;
11 11
     }
12 12
     public function addConnection( $_path, $_name = "default" ) {
13
-      if(!is_string($_path))
14
-        throw new JException("Parameter must be a string.", 1);
13
+      if(!is_string($_path)) {
14
+              throw new JException("Parameter must be a string.", 1);
15
+      }
15 16
       try {
16 17
         $jConfig = new JConfig($_path);
17 18
         if($jConfig->enable) {
@@ -23,30 +24,36 @@  discard block
 block discarded – undo
23 24
       }
24 25
     }
25 26
     public function addConnectionMan( $_connection, $_name = "default") {
26
-      if(!is_object($_connection) || !is_a($_connection, "Connection"))
27
-        throw new JException("Parameter must be a Connection object.", 1);
27
+      if(!is_object($_connection) || !is_a($_connection, "Connection")) {
28
+              throw new JException("Parameter must be a Connection object.", 1);
29
+      }
28 30
       try {
29 31
         $this->connection["$_name"] = $_connection;
30 32
         $this->currentConnection = $_connection;
31
-        foreach ($this->modules as &$module)
32
-          if(isset($this->currentConnection))
33
+        foreach ($this->modules as &$module) {
34
+                  if(isset($this->currentConnection))
33 35
             $module->addConnectionMan($this->currentConnection, $_name);
36
+        }
34 37
       } catch (Exception $e) {
35 38
         throw new JException($e->getMessage(), 1);
36 39
       }
37 40
     }
38 41
     public function setConnection( $_name = "default" ) {
39
-      if(!is_string($_name))
40
-        throw new JException("Parameter must be a string.", 1);
41
-      if(!isset($this->connection["$_name"]))
42
-        throw new JException("This connection name does not exist.", 1);
42
+      if(!is_string($_name)) {
43
+              throw new JException("Parameter must be a string.", 1);
44
+      }
45
+      if(!isset($this->connection["$_name"])) {
46
+              throw new JException("This connection name does not exist.", 1);
47
+      }
43 48
       $this->currentConnection = $this->connection["$_name"];
44 49
     }
45 50
     public function query( $_query ) {
46
-      if(!is_string($_query))
47
-        throw new JException("Parameter must be a string.", 1);
48
-      if($this->currentConnection == null)
49
-        throw new JException("No connection selected.", 1);
51
+      if(!is_string($_query)) {
52
+              throw new JException("Parameter must be a string.", 1);
53
+      }
54
+      if($this->currentConnection == null) {
55
+              throw new JException("No connection selected.", 1);
56
+      }
50 57
       try {
51 58
         $temp = $this->currentConnection->database->query($_query);
52 59
       } catch (Exception $e) {
@@ -55,10 +62,12 @@  discard block
 block discarded – undo
55 62
       return $temp;
56 63
     }
57 64
     public function queryInsert( $_query ) {
58
-      if(!is_string($_query))
59
-        throw new JException("Parameter must be a string.", 1);
60
-      if($this->currentConnection == null)
61
-        throw new JException("No connection selected.", 1);
65
+      if(!is_string($_query)) {
66
+              throw new JException("Parameter must be a string.", 1);
67
+      }
68
+      if($this->currentConnection == null) {
69
+              throw new JException("No connection selected.", 1);
70
+      }
62 71
       try {
63 72
         $temp = $this->currentConnection->database->queryInsert($_query);
64 73
       } catch (Exception $e) {
@@ -67,10 +76,12 @@  discard block
 block discarded – undo
67 76
       return $temp;
68 77
     }
69 78
     public function queryFetch( $_query ) {
70
-      if(!is_string($_query))
71
-        throw new JException("Parameter must be a string.", 1);
72
-      if($this->currentConnection == null)
73
-        throw new JException("No connection selected.", 1);
79
+      if(!is_string($_query)) {
80
+              throw new JException("Parameter must be a string.", 1);
81
+      }
82
+      if($this->currentConnection == null) {
83
+              throw new JException("No connection selected.", 1);
84
+      }
74 85
       try {
75 86
         $temp = $this->currentConnection->database->queryFetch($_query);
76 87
       } catch (Exception $e) {
@@ -79,10 +90,12 @@  discard block
 block discarded – undo
79 90
       return $temp;
80 91
     }
81 92
     public function queryArray( $_query ) {
82
-      if(!is_string($_query))
83
-        throw new JException("Parameter must be a string.", 1);
84
-      if($this->currentConnection == null)
85
-        throw new JException("No connection selected.", 1);
93
+      if(!is_string($_query)) {
94
+              throw new JException("Parameter must be a string.", 1);
95
+      }
96
+      if($this->currentConnection == null) {
97
+              throw new JException("No connection selected.", 1);
98
+      }
86 99
       try {
87 100
         $temp = $this->currentConnection->database->queryArray($_query);
88 101
       } catch (Exception $e) {
@@ -91,10 +104,12 @@  discard block
 block discarded – undo
91 104
       return $temp;
92 105
     }
93 106
     public function newTable( $_query ) {
94
-      if(!is_string($_query))
95
-        throw new JException("Parameter must be a string.", 1);
96
-      if($this->currentConnection == null)
97
-        throw new JException("No connection selected.", 1);
107
+      if(!is_string($_query)) {
108
+              throw new JException("Parameter must be a string.", 1);
109
+      }
110
+      if($this->currentConnection == null) {
111
+              throw new JException("No connection selected.", 1);
112
+      }
98 113
       try {
99 114
         $temp = $this->currentConnection->database->newTable($_query);
100 115
       } catch (Exception $e) {
Please login to merge, or discard this patch.