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