Passed
Push — master ( 7ff405...d0230e )
by Adrian
01:39
created
src/Traits/Limit.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,48 +15,48 @@
 block discarded – undo
15 15
 trait Limit
16 16
 {
17 17
 
18
-    use Objects;
18
+	use Objects;
19 19
 
20 20
 
21
-    /**
22
-     * @param int $limit
23
-     * @param null $offset
24
-     * @return $this
25
-     * @throws QueryException
26
-     */
27
-    public function limit($limit = 0, $offset = null)
28
-    {
29
-        $limit = trim($limit);
21
+	/**
22
+	 * @param int $limit
23
+	 * @param null $offset
24
+	 * @return $this
25
+	 * @throws QueryException
26
+	 */
27
+	public function limit($limit = 0, $offset = null)
28
+	{
29
+		$limit = trim($limit);
30 30
 
31
-        if (!QueryHelper::isInteger($limit))
32
-            throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT);
31
+		if (!QueryHelper::isInteger($limit))
32
+			throw new QueryException('Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT);
33 33
 
34
-        if ($limit == 0)
35
-            throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO);
34
+		if ($limit == 0)
35
+			throw new QueryException('Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO);
36 36
 
37
-        if (is_null($offset)) {
38
-            $this->queryStructure->setElement(QueryStructure::LIMIT, $limit);
37
+		if (is_null($offset)) {
38
+			$this->queryStructure->setElement(QueryStructure::LIMIT, $limit);
39 39
 
40
-            return $this;
41
-        }
40
+			return $this;
41
+		}
42 42
 
43
-        $offset = trim($offset);
43
+		$offset = trim($offset);
44 44
 
45
-        if (!QueryHelper::isInteger($offset))
46
-            throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET);
45
+		if (!QueryHelper::isInteger($offset))
46
+			throw new QueryException('Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET);
47 47
 
48
-        $this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit);
48
+		$this->queryStructure->setElement(QueryStructure::LIMIT, $offset . ',' . $limit);
49 49
 
50
-        return $this;
51
-    }
50
+		return $this;
51
+	}
52 52
 
53
-    private function getLimitSyntax()
54
-    {
55
-        if (!$this->queryStructure->getElement(QueryStructure::LIMIT))
56
-            return '';
53
+	private function getLimitSyntax()
54
+	{
55
+		if (!$this->queryStructure->getElement(QueryStructure::LIMIT))
56
+			return '';
57 57
 
58
-        return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT);
59
-    }
58
+		return 'LIMIT ' . $this->queryStructure->getElement(QueryStructure::LIMIT);
59
+	}
60 60
 
61 61
 }
62 62
 
Please login to merge, or discard this patch.
src/Traits/ColumnValidation.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@
 block discarded – undo
12 12
 trait ColumnValidation
13 13
 {
14 14
 
15
-    use Objects;
15
+	use Objects;
16 16
 
17
-    protected function validateColumn($columnName, array $allowed)
18
-    {
19
-        if (is_integer($columnName))
20
-            return true;
17
+	protected function validateColumn($columnName, array $allowed)
18
+	{
19
+		if (is_integer($columnName))
20
+			return true;
21 21
 
22
-        if (!count($allowed))
23
-            return true;
22
+		if (!count($allowed))
23
+			return true;
24 24
 
25
-        return false;
26
-    }
25
+		return false;
26
+	}
27 27
 
28 28
 
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/Ignore.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
 trait Ignore
15 15
 {
16 16
 
17
-    use Objects;
17
+	use Objects;
18 18
 
19
-    /**
20
-     * @return $this
21
-     */
22
-    public function ignore()
23
-    {
24
-        $this->queryStructure->setElement(QueryStructure::IGNORE, 1);
19
+	/**
20
+	 * @return $this
21
+	 */
22
+	public function ignore()
23
+	{
24
+		$this->queryStructure->setElement(QueryStructure::IGNORE, 1);
25 25
 
26
-        return $this;
27
-    }
26
+		return $this;
27
+	}
28 28
 
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/HighPriority.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
 trait HighPriority
15 15
 {
16 16
 
17
-    use Objects;
17
+	use Objects;
18 18
 
19
-    /**
20
-     * @return $this
21
-     */
22
-    public function highPriority()
23
-    {
24
-        $this->queryStructure->setElement(QueryStructure::PRIORITY, 'HIGH_PRIORITY');
19
+	/**
20
+	 * @return $this
21
+	 */
22
+	public function highPriority()
23
+	{
24
+		$this->queryStructure->setElement(QueryStructure::PRIORITY, 'HIGH_PRIORITY');
25 25
 
26
-        return $this;
27
-    }
26
+		return $this;
27
+	}
28 28
 
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/DefaultPriority.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
 trait DefaultPriority
15 15
 {
16 16
 
17
-    use Objects;
17
+	use Objects;
18 18
 
19 19
 
20
-    /**
21
-     * @return $this
22
-     */
23
-    public function defaultPriority()
24
-    {
25
-        $this->queryStructure->setElement(QueryStructure::PRIORITY, '');
20
+	/**
21
+	 * @return $this
22
+	 */
23
+	public function defaultPriority()
24
+	{
25
+		$this->queryStructure->setElement(QueryStructure::PRIORITY, '');
26 26
 
27
-        return $this;
28
-    }
27
+		return $this;
28
+	}
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Dependencies/QueryException.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
 class QueryException extends \Exception
12 12
 {
13 13
 
14
-    const QUERY_ERROR_ELEMENT_NOT_FOUND = 10;
15
-    const QUERY_ERROR_ELEMENT_TYPE = 11;
16
-    const QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY = 20;
17
-    const QUERY_ERROR_WHERE_INVALID_OPERATOR = 30;
18
-    const QUERY_ERROR_INVALID_LIMIT = 40;
19
-    const QUERY_ERROR_INVALID_LIMIT_ZERO = 50;
20
-    const QUERY_ERROR_INVALID_LIMIT_OFFSET = 60;
21
-    const QUERY_ERROR_DELETE_NOT_FILTER = 70;
14
+	const QUERY_ERROR_ELEMENT_NOT_FOUND = 10;
15
+	const QUERY_ERROR_ELEMENT_TYPE = 11;
16
+	const QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY = 20;
17
+	const QUERY_ERROR_WHERE_INVALID_OPERATOR = 30;
18
+	const QUERY_ERROR_INVALID_LIMIT = 40;
19
+	const QUERY_ERROR_INVALID_LIMIT_ZERO = 50;
20
+	const QUERY_ERROR_INVALID_LIMIT_OFFSET = 60;
21
+	const QUERY_ERROR_DELETE_NOT_FILTER = 70;
22 22
 
23
-    const QUERY_ERROR_INVALID_FIELDS_COUNT = 91;
24
-    const QUERY_ERROR_INVALID_DISTINCT = 92;
25
-    const QUERY_ERROR_HAVING_INVALID_PARAM_ARRAY = 93;
26
-    const QUERY_ERROR_HAVING_INVALID_OPERATOR = 94;
27
-    const QUERY_ERROR_SELECT_INVALID_FIELD = 95;
28
-    const QUERY_ERROR_SELECT_INVALID_PARAM = 96;
29
-    const QUERY_ERROR_INVALID_TABLE_STATEMENT = 97;
30
-    const QUERY_ERROR_INVALID_COLUMN_NAME = 98;
31
-    const QUERY_ERROR_INVALID_CONDITION_TYPE = 99;
23
+	const QUERY_ERROR_INVALID_FIELDS_COUNT = 91;
24
+	const QUERY_ERROR_INVALID_DISTINCT = 92;
25
+	const QUERY_ERROR_HAVING_INVALID_PARAM_ARRAY = 93;
26
+	const QUERY_ERROR_HAVING_INVALID_OPERATOR = 94;
27
+	const QUERY_ERROR_SELECT_INVALID_FIELD = 95;
28
+	const QUERY_ERROR_SELECT_INVALID_PARAM = 96;
29
+	const QUERY_ERROR_INVALID_TABLE_STATEMENT = 97;
30
+	const QUERY_ERROR_INVALID_COLUMN_NAME = 98;
31
+	const QUERY_ERROR_INVALID_CONDITION_TYPE = 99;
32 32
 
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Dependencies/QueryTimer.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,33 +11,33 @@
 block discarded – undo
11 11
 class QueryTimer
12 12
 {
13 13
 
14
-    /**
15
-     * @var mixed
16
-     */
17
-    private $queryStart;
18
-
19
-    /**
20
-     * @var mixed
21
-     */
22
-    private $queryEnd;
23
-
24
-
25
-    /**
26
-     * QueryTimer constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->queryStart = microtime(true);
31
-    }
32
-
33
-    /**
34
-     * @return float
35
-     */
36
-    public function getDuration()
37
-    {
38
-        $this->queryEnd = microtime(true);
39
-
40
-        return $this->queryEnd - $this->queryStart;
41
-    }
14
+	/**
15
+	 * @var mixed
16
+	 */
17
+	private $queryStart;
18
+
19
+	/**
20
+	 * @var mixed
21
+	 */
22
+	private $queryEnd;
23
+
24
+
25
+	/**
26
+	 * QueryTimer constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->queryStart = microtime(true);
31
+	}
32
+
33
+	/**
34
+	 * @return float
35
+	 */
36
+	public function getDuration()
37
+	{
38
+		$this->queryEnd = microtime(true);
39
+
40
+		return $this->queryEnd - $this->queryStart;
41
+	}
42 42
 
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
src/QueryBuild.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -17,71 +17,71 @@
 block discarded – undo
17 17
 class QueryBuild
18 18
 {
19 19
 
20
-    /**
21
-     * @var integer
22
-     */
23
-    private $queryType;
20
+	/**
21
+	 * @var integer
22
+	 */
23
+	private $queryType;
24 24
 
25
-    /**
26
-     * QueryBuild constructor.
27
-     * @param $queryType
28
-     */
29
-    protected function __construct($queryType)
30
-    {
31
-        $this->queryType = $queryType;
32
-    }
25
+	/**
26
+	 * QueryBuild constructor.
27
+	 * @param $queryType
28
+	 */
29
+	protected function __construct($queryType)
30
+	{
31
+		$this->queryType = $queryType;
32
+	}
33 33
 
34
-    /**
35
-     * @param $table
36
-     * @return QuerySelect
37
-     */
38
-    public static function select($table)
39
-    {
40
-        return new QuerySelect(new QueryBuild(0), $table);
41
-    }
34
+	/**
35
+	 * @param $table
36
+	 * @return QuerySelect
37
+	 */
38
+	public static function select($table)
39
+	{
40
+		return new QuerySelect(new QueryBuild(0), $table);
41
+	}
42 42
 
43
-    /**
44
-     * @param $table
45
-     * @return QueryUpdate
46
-     */
47
-    public static function update($table)
48
-    {
49
-        return new QueryUpdate(new QueryBuild(0), $table);
50
-    }
43
+	/**
44
+	 * @param $table
45
+	 * @return QueryUpdate
46
+	 */
47
+	public static function update($table)
48
+	{
49
+		return new QueryUpdate(new QueryBuild(0), $table);
50
+	}
51 51
 
52
-    /**
53
-     * @param $table
54
-     * @return QueryInsert
55
-     */
56
-    public static function insert($table)
57
-    {
58
-        return new QueryInsert(new QueryBuild(0), $table);
59
-    }
52
+	/**
53
+	 * @param $table
54
+	 * @return QueryInsert
55
+	 */
56
+	public static function insert($table)
57
+	{
58
+		return new QueryInsert(new QueryBuild(0), $table);
59
+	}
60 60
 
61
-    /**
62
-     * @param $table
63
-     * @return QueryDelete
64
-     */
65
-    public static function delete($table)
66
-    {
67
-        return new QueryDelete(new QueryBuild(0), $table);
68
-    }
61
+	/**
62
+	 * @param $table
63
+	 * @return QueryDelete
64
+	 */
65
+	public static function delete($table)
66
+	{
67
+		return new QueryDelete(new QueryBuild(0), $table);
68
+	}
69 69
 
70
-    /**
71
-     * @param $query
72
-     * @return QueryCustom
73
-     */
74
-    public static function query($query)
75
-    {
76
-        return new QueryCustom(new QueryBuild(1), $query);
77
-    }
70
+	/**
71
+	 * @param $query
72
+	 * @return QueryCustom
73
+	 */
74
+	public static function query($query)
75
+	{
76
+		return new QueryCustom(new QueryBuild(1), $query);
77
+	}
78 78
 
79
-    /**
80
-     * @return integer
81
-     */
82
-    public function getType()
83
-    {
84
-        return $this->queryType;
85
-    }
79
+	/**
80
+	 * @return integer
81
+	 */
82
+	public function getType()
83
+	{
84
+		return $this->queryType;
85
+	}
86 86
 
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
src/Statements/QuerySelect.php 1 patch
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -29,179 +29,179 @@
 block discarded – undo
29 29
 class QuerySelect extends QueryStatement implements QueryStatementInterface
30 30
 {
31 31
 
32
-    use SelectFields, Limit, Distinct, Where, Having, WhereAndHavingBuilder, Replacement, OrderBy, GroupBy, Join, DefaultPriority, HighPriority, Utilities;
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    protected $statement = self::QUERY_STATEMENT_SELECT;
38
-
39
-
40
-    /**
41
-     * QuerySelect constructor.
42
-     * @param QueryBuild $queryBuild
43
-     * @param string|QueryStatement $table
44
-     */
45
-    public function __construct(QueryBuild $queryBuild, $table)
46
-    {
47
-        parent::__construct($queryBuild, $table);
48
-
49
-        if (is_a($table, QuerySelect::class)) {
50
-
51
-            /**
52
-             * @var QuerySelect $table
53
-             */
54
-            $tableName = '( ' . $table->getSyntax() . ' )';
55
-            $this->queryStructure->setElement(QueryStructure::TABLE, $tableName);
56
-
57
-            $tableSelectParams = $table->getBindParams();
58
-            foreach ($tableSelectParams as $key => $value)
59
-                $this->queryStructure->setParams($key, $value);
60
-
61
-        }
62
-    }
63
-
64
-    /**
65
-     * @return $this
66
-     */
67
-    public function first()
68
-    {
69
-        $this->queryStructure->setElement(QueryStructure::FIRST, 1);
70
-
71
-        return $this;
72
-    }
73
-
74
-    /**
75
-     * @return $this
76
-     */
77
-    public function count()
78
-    {
79
-        $this->queryStructure->setElement(QueryStructure::COUNT, 1);
80
-
81
-        return $this;
82
-    }
83
-
84
-    /**
85
-     * @param $column
86
-     * @return $this
87
-     */
88
-    public function column($column)
89
-    {
90
-        $column = QueryHelper::clearMultipleSpaces($column);
91
-        $this->queryStructure->setElement(QueryStructure::COLUMN, $column);
92
-
93
-        return $this;
94
-    }
95
-
96
-
97
-    /**
98
-     * @param bool|int $replacement
99
-     * @return mixed|string
100
-     */
101
-    public function getSyntax($replacement = self::REPLACEMENT_NONE)
102
-    {
103
-
104
-        if ($this->queryStructure->getElement(QueryStructure::COUNT)) {
105
-            $this->queryStructure->setElement(QueryStructure::FIELDS, 'COUNT(*)');
106
-            $this->queryStructure->setElement(QueryStructure::LIMIT, 1);
107
-            $this->queryStructure->setElement(QueryStructure::DISTINCT, 0); //???
108
-        }
109
-
110
-        if ($this->queryStructure->getElement(QueryStructure::FIRST))
111
-            $this->queryStructure->setElement(QueryStructure::LIMIT, 1);
112
-
113
-        $syntax = array();
114
-
115
-        /**
116
-         *  Explain
117
-         */
118
-        $syntax[] = $this->getExplainSyntax();
119
-
120
-        /**
121
-         * SELECT statement
122
-         */
123
-        $syntax[] = $this->statement;
124
-
125
-        /**
126
-         * PRIORITY
127
-         */
128
-        $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY);
129
-
130
-        /**
131
-         * DISTINCT clause
132
-         */
133
-        $syntax[] = $this->getDistinctSyntax();
134
-
135
-        /**
136
-         * FIELDS
137
-         */
138
-        $syntax[] = $this->queryStructure->getElement(QueryStructure::FIELDS);
139
-
140
-        /**
141
-         * FROM table or queryStructure
142
-         */
143
-        $syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE);
144
-
145
-        /**
146
-         * JOIN CLAUSES
147
-         */
148
-        $syntax[] = $this->getJoinSyntax();
149
-
150
-        /**
151
-         * WHERE clause
152
-         */
153
-        $syntax[] = $this->getWhereSyntax();
154
-
155
-        /**
156
-         * GROUP BY clause
157
-         */
158
-        $syntax[] = $this->getGroupBySyntax();
159
-
160
-        /**
161
-         * HAVING clause
162
-         */
163
-        $syntax[] = $this->getHavingSyntax();
164
-
165
-        /**
166
-         * ORDER BY clause
167
-         */
168
-        $syntax[] = $this->getOrderBySyntax();
169
-
170
-        /**
171
-         * LIMIT clause
172
-         */
173
-        $syntax[] = $this->getLimitSyntax();
174
-
175
-        $syntax = implode(' ', $syntax);
176
-
177
-        return $this->getSyntaxReplace($syntax, $replacement);
178
-
179
-    }
180
-
181
-
182
-    /**
183
-     * @return array|int|mixed|null|string
184
-     */
185
-    public function execute()
186
-    {
187
-
188
-        switch (true) {
189
-            case $this->queryStructure->getElement(QueryStructure::COUNT):
190
-                return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
191
-                break;
192
-            case $this->queryStructure->getElement(QueryStructure::FIRST):
193
-                if ($this->queryStructure->getElement(QueryStructure::COLUMN))
194
-                    return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
195
-
196
-                return DbService::getInstance()->row($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
197
-                break;
198
-            case $this->queryStructure->getElement(QueryStructure::COLUMN):
199
-                return DbService::getInstance()->column($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
200
-                break;
201
-            default:
202
-                return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
203
-                break;
204
-        }
205
-    }
32
+	use SelectFields, Limit, Distinct, Where, Having, WhereAndHavingBuilder, Replacement, OrderBy, GroupBy, Join, DefaultPriority, HighPriority, Utilities;
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	protected $statement = self::QUERY_STATEMENT_SELECT;
38
+
39
+
40
+	/**
41
+	 * QuerySelect constructor.
42
+	 * @param QueryBuild $queryBuild
43
+	 * @param string|QueryStatement $table
44
+	 */
45
+	public function __construct(QueryBuild $queryBuild, $table)
46
+	{
47
+		parent::__construct($queryBuild, $table);
48
+
49
+		if (is_a($table, QuerySelect::class)) {
50
+
51
+			/**
52
+			 * @var QuerySelect $table
53
+			 */
54
+			$tableName = '( ' . $table->getSyntax() . ' )';
55
+			$this->queryStructure->setElement(QueryStructure::TABLE, $tableName);
56
+
57
+			$tableSelectParams = $table->getBindParams();
58
+			foreach ($tableSelectParams as $key => $value)
59
+				$this->queryStructure->setParams($key, $value);
60
+
61
+		}
62
+	}
63
+
64
+	/**
65
+	 * @return $this
66
+	 */
67
+	public function first()
68
+	{
69
+		$this->queryStructure->setElement(QueryStructure::FIRST, 1);
70
+
71
+		return $this;
72
+	}
73
+
74
+	/**
75
+	 * @return $this
76
+	 */
77
+	public function count()
78
+	{
79
+		$this->queryStructure->setElement(QueryStructure::COUNT, 1);
80
+
81
+		return $this;
82
+	}
83
+
84
+	/**
85
+	 * @param $column
86
+	 * @return $this
87
+	 */
88
+	public function column($column)
89
+	{
90
+		$column = QueryHelper::clearMultipleSpaces($column);
91
+		$this->queryStructure->setElement(QueryStructure::COLUMN, $column);
92
+
93
+		return $this;
94
+	}
95
+
96
+
97
+	/**
98
+	 * @param bool|int $replacement
99
+	 * @return mixed|string
100
+	 */
101
+	public function getSyntax($replacement = self::REPLACEMENT_NONE)
102
+	{
103
+
104
+		if ($this->queryStructure->getElement(QueryStructure::COUNT)) {
105
+			$this->queryStructure->setElement(QueryStructure::FIELDS, 'COUNT(*)');
106
+			$this->queryStructure->setElement(QueryStructure::LIMIT, 1);
107
+			$this->queryStructure->setElement(QueryStructure::DISTINCT, 0); //???
108
+		}
109
+
110
+		if ($this->queryStructure->getElement(QueryStructure::FIRST))
111
+			$this->queryStructure->setElement(QueryStructure::LIMIT, 1);
112
+
113
+		$syntax = array();
114
+
115
+		/**
116
+		 *  Explain
117
+		 */
118
+		$syntax[] = $this->getExplainSyntax();
119
+
120
+		/**
121
+		 * SELECT statement
122
+		 */
123
+		$syntax[] = $this->statement;
124
+
125
+		/**
126
+		 * PRIORITY
127
+		 */
128
+		$syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY);
129
+
130
+		/**
131
+		 * DISTINCT clause
132
+		 */
133
+		$syntax[] = $this->getDistinctSyntax();
134
+
135
+		/**
136
+		 * FIELDS
137
+		 */
138
+		$syntax[] = $this->queryStructure->getElement(QueryStructure::FIELDS);
139
+
140
+		/**
141
+		 * FROM table or queryStructure
142
+		 */
143
+		$syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE);
144
+
145
+		/**
146
+		 * JOIN CLAUSES
147
+		 */
148
+		$syntax[] = $this->getJoinSyntax();
149
+
150
+		/**
151
+		 * WHERE clause
152
+		 */
153
+		$syntax[] = $this->getWhereSyntax();
154
+
155
+		/**
156
+		 * GROUP BY clause
157
+		 */
158
+		$syntax[] = $this->getGroupBySyntax();
159
+
160
+		/**
161
+		 * HAVING clause
162
+		 */
163
+		$syntax[] = $this->getHavingSyntax();
164
+
165
+		/**
166
+		 * ORDER BY clause
167
+		 */
168
+		$syntax[] = $this->getOrderBySyntax();
169
+
170
+		/**
171
+		 * LIMIT clause
172
+		 */
173
+		$syntax[] = $this->getLimitSyntax();
174
+
175
+		$syntax = implode(' ', $syntax);
176
+
177
+		return $this->getSyntaxReplace($syntax, $replacement);
178
+
179
+	}
180
+
181
+
182
+	/**
183
+	 * @return array|int|mixed|null|string
184
+	 */
185
+	public function execute()
186
+	{
187
+
188
+		switch (true) {
189
+			case $this->queryStructure->getElement(QueryStructure::COUNT):
190
+				return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
191
+				break;
192
+			case $this->queryStructure->getElement(QueryStructure::FIRST):
193
+				if ($this->queryStructure->getElement(QueryStructure::COLUMN))
194
+					return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
195
+
196
+				return DbService::getInstance()->row($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
197
+				break;
198
+			case $this->queryStructure->getElement(QueryStructure::COLUMN):
199
+				return DbService::getInstance()->column($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
200
+				break;
201
+			default:
202
+				return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS));
203
+				break;
204
+		}
205
+	}
206 206
 
207 207
 }
208 208
\ No newline at end of file
Please login to merge, or discard this patch.