Passed
Push — master ( c6058f...e9743f )
by Richard
04:06
created
maphper/datasource/mysqladapter.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	public function query(\Maphper\Lib\Query $query) {
28 28
 		$stmt = $this->getCachedStmt($query->getSql());
29 29
 		$args = $query->getArgs();
30
-        $stmt->execute($args);
30
+		$stmt->execute($args);
31 31
 
32 32
 		if (strpos(trim($query->getSql()), 'SELECT') === 0) return $stmt->fetchAll(\PDO::FETCH_OBJ);
33 33
 		else return $stmt;
Please login to merge, or discard this patch.
maphper/datasource/sqliteadapter.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		return '`' . str_replace('.', '`.`', trim($str, '`')) . '`';
14 14
 	}
15 15
 
16
-    private function getCachedStmt($sql) {
16
+	private function getCachedStmt($sql) {
17 17
 		$queryId = md5($sql);
18 18
 		if (isset($this->queryCache[$queryId])) $stmt = $this->queryCache[$queryId];
19 19
 		else {
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 
26 26
 	public function query(\Maphper\Lib\Query $query) {
27 27
 		$queryId = md5($query->getSql());
28
-        $stmt = $this->getCachedStmt($query->getSql());
28
+		$stmt = $this->getCachedStmt($query->getSql());
29 29
 		$args = $query->getArgs();
30 30
 
31
-        //Handle SQLite when PDO_ERRMODE is set to SILENT
32
-        if ($stmt === false) throw new \Exception('Invalid query');
31
+		//Handle SQLite when PDO_ERRMODE is set to SILENT
32
+		if ($stmt === false) throw new \Exception('Invalid query');
33 33
 
34
-        $stmt->execute($args);
35
-        if ($stmt->errorCode() !== '00000' && $stmt->errorInfo()[2] == 'database schema has changed') {
34
+		$stmt->execute($args);
35
+		if ($stmt->errorCode() !== '00000' && $stmt->errorInfo()[2] == 'database schema has changed') {
36 36
 			unset($this->queryCache[$queryId]);
37 37
 			return $this->query($query);
38
-        }
38
+		}
39 39
 
40
-        if (substr($query->getSql(), 0, 6) === 'SELECT') return $stmt->fetchAll(\PDO::FETCH_OBJ);
41
-        else return $stmt;
40
+		if (substr($query->getSql(), 0, 6) === 'SELECT') return $stmt->fetchAll(\PDO::FETCH_OBJ);
41
+		else return $stmt;
42 42
 	}
43 43
 	
44 44
 	public function lastInsertId() {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	private function tableExists($name) {
58
-		$result = $this->pdo->query('SELECT name FROM sqlite_master WHERE type="table" and name="'. $name.'"');
58
+		$result = $this->pdo->query('SELECT name FROM sqlite_master WHERE type="table" and name="' . $name . '"');
59 59
 		return count($result->fetchAll()) == 1;
60 60
 	}
61 61
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		// SQLSTATE[HY000]: General error: 17 database schema has changed
75 75
 		$this->queryCache = [];
76 76
 
77
-		$affix = '_'.substr(md5($table), 0, 6);
77
+		$affix = '_' . substr(md5($table), 0, 6);
78 78
 		$this->createTable($table . $affix, $primaryKey, $data);
79 79
 		$fields = [];
80 80
 		foreach ($data as $key => $value) { $fields[] = $key; }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 				$columns = implode(', ', $this->getColumns($table));			
84 84
 
85 85
 				$this->pdo->query('INSERT INTO ' . $this->quote($table . $affix) . '(' . $columns . ') SELECT ' . $columns . ' FROM ' . $this->quote($table));
86
-				$this->pdo->query('DROP TABLE IF EXISTS ' . $table );
86
+				$this->pdo->query('DROP TABLE IF EXISTS ' . $table);
87 87
 			}
88 88
 		}
89 89
 		catch (\PDOException $e) {
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 			echo $e->getMessage();
92 92
 		}
93 93
 
94
-		$this->pdo->query('DROP TABLE IF EXISTS ' . $table );
95
-		$this->pdo->query('ALTER TABLE ' . $table . $affix. ' RENAME TO '. $table );
94
+		$this->pdo->query('DROP TABLE IF EXISTS ' . $table);
95
+		$this->pdo->query('ALTER TABLE ' . $table . $affix . ' RENAME TO ' . $table);
96 96
 
97 97
 	}
98 98
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		
107 107
 		$pkField = implode(', ', $parts) . ', PRIMARY KEY(' . implode(', ', $primaryKey) . ')';
108 108
 				
109
-		$this->pdo->query('DROP TABLE IF EXISTS ' . $table );
109
+		$this->pdo->query('DROP TABLE IF EXISTS ' . $table);
110 110
 		$this->pdo->query('CREATE TABLE ' . $table . ' (' . $pkField . ')');
111 111
 					
112 112
 		foreach ($data as $key => $value) {
Please login to merge, or discard this patch.
maphper/lib/selectbuilder.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 		$sql = [];
31 31
 
32 32
 		foreach ($fields as $key => $value) {
33
-            if ($value instanceof \DateTime) {
34
-    			if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
35
-    			else $value = $value->format('Y-m-d H:i:s');
36
-    		}
33
+			if ($value instanceof \DateTime) {
34
+				if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
35
+				else $value = $value->format('Y-m-d H:i:s');
36
+			}
37 37
 
38 38
 			if (is_numeric($key) && is_array($value)) {
39 39
 				$result = $this->createSql($value, $key);
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 		return ['args' => $args, 'sql' => [$query]];
86 86
 	}
87 87
 
88
-    private function getOperator($mode) {
89
-        $operator = "";
88
+	private function getOperator($mode) {
89
+		$operator = "";
90 90
 
91
-        if (\Maphper\Maphper::FIND_NOCASE & $mode) $operator = 'LIKE';
92
-        else if (\Maphper\Maphper::FIND_BIT & $mode) $operator = '&';
93
-        else if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>';
94
-        else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<';
95
-        else if (\Maphper\Maphper::FIND_NOT & $mode) $operator = '!=';
91
+		if (\Maphper\Maphper::FIND_NOCASE & $mode) $operator = 'LIKE';
92
+		else if (\Maphper\Maphper::FIND_BIT & $mode) $operator = '&';
93
+		else if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>';
94
+		else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<';
95
+		else if (\Maphper\Maphper::FIND_NOT & $mode) $operator = '!=';
96 96
 
97
-        if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '=';
97
+		if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '=';
98 98
 
99
-        return $operator;
100
-    }
99
+		return $operator;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 	//Needs to be broken up into better methods
28
-	public function createSql($fields, $mode){
28
+	public function createSql($fields, $mode) {
29 29
 		$args = [];
30 30
 		$sql = [];
31 31
 
32 32
 		foreach ($fields as $key => $value) {
33 33
             if ($value instanceof \DateTime) {
34
-    			if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
34
+    			if ($value->format('H:i:s') == '00:00:00') $value = $value->format('Y-m-d');
35 35
     			else $value = $value->format('Y-m-d H:i:s');
36 36
     		}
37 37
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 					$inSql[] = ':' . $key . $i;
56 56
 				}
57 57
 				if (count($inSql) == 0) return [];
58
-				else $sql[] = $key . ' IN ( ' .  implode(', ', $inSql) . ')';
58
+				else $sql[] = $key . ' IN ( ' . implode(', ', $inSql) . ')';
59 59
 			}
60 60
 			else if ($value === NULL) {
61 61
 				$nullSql = $key . ' IS ';
Please login to merge, or discard this patch.