@@ -17,71 +17,71 @@ |
||
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 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * QueryBuild constructor. |
27 | 27 | * @param $queryType |
28 | 28 | */ |
29 | - protected function __construct($queryType) |
|
29 | + protected function __construct( $queryType ) |
|
30 | 30 | { |
31 | 31 | $this->queryType = $queryType; |
32 | 32 | } |
@@ -35,45 +35,45 @@ discard block |
||
35 | 35 | * @param $table |
36 | 36 | * @return QuerySelect |
37 | 37 | */ |
38 | - public static function select($table) |
|
38 | + public static function select( $table ) |
|
39 | 39 | { |
40 | - return new QuerySelect(new QueryBuild(0), $table); |
|
40 | + return new QuerySelect( new QueryBuild( 0 ), $table ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param $table |
45 | 45 | * @return QueryUpdate |
46 | 46 | */ |
47 | - public static function update($table) |
|
47 | + public static function update( $table ) |
|
48 | 48 | { |
49 | - return new QueryUpdate(new QueryBuild(0), $table); |
|
49 | + return new QueryUpdate( new QueryBuild( 0 ), $table ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param $table |
54 | 54 | * @return QueryInsert |
55 | 55 | */ |
56 | - public static function insert($table) |
|
56 | + public static function insert( $table ) |
|
57 | 57 | { |
58 | - return new QueryInsert(new QueryBuild(0), $table); |
|
58 | + return new QueryInsert( new QueryBuild( 0 ), $table ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param $table |
63 | 63 | * @return QueryDelete |
64 | 64 | */ |
65 | - public static function delete($table) |
|
65 | + public static function delete( $table ) |
|
66 | 66 | { |
67 | - return new QueryDelete(new QueryBuild(0), $table); |
|
67 | + return new QueryDelete( new QueryBuild( 0 ), $table ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @param $query |
72 | 72 | * @return QueryCustom |
73 | 73 | */ |
74 | - public static function query($query) |
|
74 | + public static function query( $query ) |
|
75 | 75 | { |
76 | - return new QueryCustom(new QueryBuild(1), $query); |
|
76 | + return new QueryCustom( new QueryBuild( 1 ), $query ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -29,179 +29,179 @@ |
||
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 |
@@ -42,21 +42,21 @@ discard block |
||
42 | 42 | * @param QueryBuild $queryBuild |
43 | 43 | * @param string|QueryStatement $table |
44 | 44 | */ |
45 | - public function __construct(QueryBuild $queryBuild, $table) |
|
45 | + public function __construct( QueryBuild $queryBuild, $table ) |
|
46 | 46 | { |
47 | - parent::__construct($queryBuild, $table); |
|
47 | + parent::__construct( $queryBuild, $table ); |
|
48 | 48 | |
49 | - if (is_a($table, QuerySelect::class)) { |
|
49 | + if ( is_a( $table, QuerySelect::class ) ) { |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var QuerySelect $table |
53 | 53 | */ |
54 | 54 | $tableName = '( ' . $table->getSyntax() . ' )'; |
55 | - $this->queryStructure->setElement(QueryStructure::TABLE, $tableName); |
|
55 | + $this->queryStructure->setElement( QueryStructure::TABLE, $tableName ); |
|
56 | 56 | |
57 | 57 | $tableSelectParams = $table->getBindParams(); |
58 | - foreach ($tableSelectParams as $key => $value) |
|
59 | - $this->queryStructure->setParams($key, $value); |
|
58 | + foreach ( $tableSelectParams as $key => $value ) |
|
59 | + $this->queryStructure->setParams( $key, $value ); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function first() |
68 | 68 | { |
69 | - $this->queryStructure->setElement(QueryStructure::FIRST, 1); |
|
69 | + $this->queryStructure->setElement( QueryStructure::FIRST, 1 ); |
|
70 | 70 | |
71 | 71 | return $this; |
72 | 72 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function count() |
78 | 78 | { |
79 | - $this->queryStructure->setElement(QueryStructure::COUNT, 1); |
|
79 | + $this->queryStructure->setElement( QueryStructure::COUNT, 1 ); |
|
80 | 80 | |
81 | 81 | return $this; |
82 | 82 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | * @param $column |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - public function column($column) |
|
88 | + public function column( $column ) |
|
89 | 89 | { |
90 | - $column = QueryHelper::clearMultipleSpaces($column); |
|
91 | - $this->queryStructure->setElement(QueryStructure::COLUMN, $column); |
|
90 | + $column = QueryHelper::clearMultipleSpaces( $column ); |
|
91 | + $this->queryStructure->setElement( QueryStructure::COLUMN, $column ); |
|
92 | 92 | |
93 | 93 | return $this; |
94 | 94 | } |
@@ -98,83 +98,83 @@ discard block |
||
98 | 98 | * @param bool|int $replacement |
99 | 99 | * @return mixed|string |
100 | 100 | */ |
101 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
101 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
102 | 102 | { |
103 | 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); //??? |
|
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 | 108 | } |
109 | 109 | |
110 | - if ($this->queryStructure->getElement(QueryStructure::FIRST)) |
|
111 | - $this->queryStructure->setElement(QueryStructure::LIMIT, 1); |
|
110 | + if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) |
|
111 | + $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
112 | 112 | |
113 | 113 | $syntax = array(); |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Explain |
117 | 117 | */ |
118 | - $syntax[] = $this->getExplainSyntax(); |
|
118 | + $syntax[ ] = $this->getExplainSyntax(); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * SELECT statement |
122 | 122 | */ |
123 | - $syntax[] = $this->statement; |
|
123 | + $syntax[ ] = $this->statement; |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * PRIORITY |
127 | 127 | */ |
128 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
128 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * DISTINCT clause |
132 | 132 | */ |
133 | - $syntax[] = $this->getDistinctSyntax(); |
|
133 | + $syntax[ ] = $this->getDistinctSyntax(); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * FIELDS |
137 | 137 | */ |
138 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::FIELDS); |
|
138 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * FROM table or queryStructure |
142 | 142 | */ |
143 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
143 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * JOIN CLAUSES |
147 | 147 | */ |
148 | - $syntax[] = $this->getJoinSyntax(); |
|
148 | + $syntax[ ] = $this->getJoinSyntax(); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * WHERE clause |
152 | 152 | */ |
153 | - $syntax[] = $this->getWhereSyntax(); |
|
153 | + $syntax[ ] = $this->getWhereSyntax(); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * GROUP BY clause |
157 | 157 | */ |
158 | - $syntax[] = $this->getGroupBySyntax(); |
|
158 | + $syntax[ ] = $this->getGroupBySyntax(); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * HAVING clause |
162 | 162 | */ |
163 | - $syntax[] = $this->getHavingSyntax(); |
|
163 | + $syntax[ ] = $this->getHavingSyntax(); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * ORDER BY clause |
167 | 167 | */ |
168 | - $syntax[] = $this->getOrderBySyntax(); |
|
168 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * LIMIT clause |
172 | 172 | */ |
173 | - $syntax[] = $this->getLimitSyntax(); |
|
173 | + $syntax[ ] = $this->getLimitSyntax(); |
|
174 | 174 | |
175 | - $syntax = implode(' ', $syntax); |
|
175 | + $syntax = implode( ' ', $syntax ); |
|
176 | 176 | |
177 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
177 | + return $this->getSyntaxReplace( $syntax, $replacement ); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -185,21 +185,21 @@ discard block |
||
185 | 185 | public function execute() |
186 | 186 | { |
187 | 187 | |
188 | - switch (true) { |
|
189 | - case $this->queryStructure->getElement(QueryStructure::COUNT): |
|
190 | - return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
188 | + switch ( true ) { |
|
189 | + case $this->queryStructure->getElement( QueryStructure::COUNT ): |
|
190 | + return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
191 | 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)); |
|
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 | 195 | |
196 | - return DbService::getInstance()->row($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
196 | + return DbService::getInstance()->row( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
197 | 197 | break; |
198 | - case $this->queryStructure->getElement(QueryStructure::COLUMN): |
|
199 | - return DbService::getInstance()->column($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
198 | + case $this->queryStructure->getElement( QueryStructure::COLUMN ): |
|
199 | + return DbService::getInstance()->column( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
200 | 200 | break; |
201 | 201 | default: |
202 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
202 | + return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | $this->queryStructure->setElement(QueryStructure::TABLE, $tableName); |
56 | 56 | |
57 | 57 | $tableSelectParams = $table->getBindParams(); |
58 | - foreach ($tableSelectParams as $key => $value) |
|
59 | - $this->queryStructure->setParams($key, $value); |
|
58 | + foreach ($tableSelectParams as $key => $value) { |
|
59 | + $this->queryStructure->setParams($key, $value); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | } |
62 | 63 | } |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | $this->queryStructure->setElement(QueryStructure::DISTINCT, 0); //??? |
108 | 109 | } |
109 | 110 | |
110 | - if ($this->queryStructure->getElement(QueryStructure::FIRST)) |
|
111 | - $this->queryStructure->setElement(QueryStructure::LIMIT, 1); |
|
111 | + if ($this->queryStructure->getElement(QueryStructure::FIRST)) { |
|
112 | + $this->queryStructure->setElement(QueryStructure::LIMIT, 1); |
|
113 | + } |
|
112 | 114 | |
113 | 115 | $syntax = array(); |
114 | 116 | |
@@ -190,8 +192,9 @@ discard block |
||
190 | 192 | return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
191 | 193 | break; |
192 | 194 | 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 | + if ($this->queryStructure->getElement(QueryStructure::COLUMN)) { |
|
196 | + return DbService::getInstance()->single($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
197 | + } |
|
195 | 198 | |
196 | 199 | return DbService::getInstance()->row($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
197 | 200 | break; |
@@ -17,81 +17,81 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $statement = QueryStatement::QUERY_STATEMENT_CUSTOM; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var QueryBuild |
|
27 | - */ |
|
28 | - protected $queryBuild; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var QueryStructure |
|
32 | - */ |
|
33 | - protected $queryStructure; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $usedInstanceIds = []; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $tablePrefix; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * QueryCustom constructor. |
|
48 | - * @param QueryBuild $queryBuild |
|
49 | - * @param string $query |
|
50 | - */ |
|
51 | - public function __construct(QueryBuild $queryBuild, $query = '') |
|
52 | - { |
|
53 | - $this->queryBuild = $queryBuild; |
|
54 | - $this->queryStructure = new QueryStructure(); |
|
55 | - $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
56 | - $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
57 | - $this->queryStructure->setElement(QueryStructure::QUERY_STRING, $query); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param array $params |
|
62 | - * @return $this |
|
63 | - */ |
|
64 | - public function withBindParams(array $params = []) |
|
65 | - { |
|
66 | - $this->queryStructure->replaceElement(QueryStructure::BIND_PARAMS, $params); |
|
67 | - |
|
68 | - return $this; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param bool|int $replacement |
|
73 | - * @return mixed |
|
74 | - */ |
|
75 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
76 | - { |
|
77 | - return $this->queryStructure->getElement(QueryStructure::QUERY_STRING); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function getBindParams() |
|
84 | - { |
|
85 | - return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return array|int|null |
|
90 | - */ |
|
91 | - public function execute() |
|
92 | - { |
|
93 | - return DbService::getInstance()->query($this->queryStructure->getElement(QueryStructure::QUERY_STRING), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
94 | - } |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $statement = QueryStatement::QUERY_STATEMENT_CUSTOM; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var QueryBuild |
|
27 | + */ |
|
28 | + protected $queryBuild; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var QueryStructure |
|
32 | + */ |
|
33 | + protected $queryStructure; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $usedInstanceIds = []; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $tablePrefix; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * QueryCustom constructor. |
|
48 | + * @param QueryBuild $queryBuild |
|
49 | + * @param string $query |
|
50 | + */ |
|
51 | + public function __construct(QueryBuild $queryBuild, $query = '') |
|
52 | + { |
|
53 | + $this->queryBuild = $queryBuild; |
|
54 | + $this->queryStructure = new QueryStructure(); |
|
55 | + $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
56 | + $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
57 | + $this->queryStructure->setElement(QueryStructure::QUERY_STRING, $query); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param array $params |
|
62 | + * @return $this |
|
63 | + */ |
|
64 | + public function withBindParams(array $params = []) |
|
65 | + { |
|
66 | + $this->queryStructure->replaceElement(QueryStructure::BIND_PARAMS, $params); |
|
67 | + |
|
68 | + return $this; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param bool|int $replacement |
|
73 | + * @return mixed |
|
74 | + */ |
|
75 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
76 | + { |
|
77 | + return $this->queryStructure->getElement(QueryStructure::QUERY_STRING); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function getBindParams() |
|
84 | + { |
|
85 | + return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return array|int|null |
|
90 | + */ |
|
91 | + public function execute() |
|
92 | + { |
|
93 | + return DbService::getInstance()->query($this->queryStructure->getElement(QueryStructure::QUERY_STRING), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var array |
37 | 37 | */ |
38 | - protected $usedInstanceIds = []; |
|
38 | + protected $usedInstanceIds = [ ]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | * @param QueryBuild $queryBuild |
49 | 49 | * @param string $query |
50 | 50 | */ |
51 | - public function __construct(QueryBuild $queryBuild, $query = '') |
|
51 | + public function __construct( QueryBuild $queryBuild, $query = '' ) |
|
52 | 52 | { |
53 | 53 | $this->queryBuild = $queryBuild; |
54 | 54 | $this->queryStructure = new QueryStructure(); |
55 | - $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
56 | - $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
57 | - $this->queryStructure->setElement(QueryStructure::QUERY_STRING, $query); |
|
55 | + $this->queryStructure->setElement( QueryStructure::STATEMENT, $this->statement ); |
|
56 | + $this->queryStructure->setElement( QueryStructure::QUERY_TYPE, $this->queryBuild->getType() ); |
|
57 | + $this->queryStructure->setElement( QueryStructure::QUERY_STRING, $query ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @param array $params |
62 | 62 | * @return $this |
63 | 63 | */ |
64 | - public function withBindParams(array $params = []) |
|
64 | + public function withBindParams( array $params = [ ] ) |
|
65 | 65 | { |
66 | - $this->queryStructure->replaceElement(QueryStructure::BIND_PARAMS, $params); |
|
66 | + $this->queryStructure->replaceElement( QueryStructure::BIND_PARAMS, $params ); |
|
67 | 67 | |
68 | 68 | return $this; |
69 | 69 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param bool|int $replacement |
73 | 73 | * @return mixed |
74 | 74 | */ |
75 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
75 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
76 | 76 | { |
77 | - return $this->queryStructure->getElement(QueryStructure::QUERY_STRING); |
|
77 | + return $this->queryStructure->getElement( QueryStructure::QUERY_STRING ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getBindParams() |
84 | 84 | { |
85 | - return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
85 | + return $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function execute() |
92 | 92 | { |
93 | - return DbService::getInstance()->query($this->queryStructure->getElement(QueryStructure::QUERY_STRING), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
93 | + return DbService::getInstance()->query( $this->queryStructure->getElement( QueryStructure::QUERY_STRING ), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 |
@@ -26,89 +26,89 @@ |
||
26 | 26 | class QueryUpdate extends QueryStatement implements QueryStatementInterface |
27 | 27 | { |
28 | 28 | |
29 | - use Limit, Where, WhereAndHavingBuilder, Replacement, OrderBy, SetFields, Ignore, DefaultPriority, LowPriority, Utilities; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $statement = self::QUERY_STATEMENT_UPDATE; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * QueryUpdate constructor. |
|
39 | - * @param QueryBuild $queryBuild |
|
40 | - * @param string $table |
|
41 | - */ |
|
42 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
43 | - { |
|
44 | - parent::__construct($queryBuild, $table); |
|
45 | - } |
|
46 | - |
|
47 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
48 | - { |
|
49 | - |
|
50 | - $syntax = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * Explain |
|
54 | - */ |
|
55 | - $syntax[] = $this->getExplainSyntax(); |
|
56 | - |
|
57 | - /** |
|
58 | - * UPDATE statement |
|
59 | - */ |
|
60 | - $syntax[] = $this->statement; |
|
61 | - |
|
62 | - /** |
|
63 | - * PRIORITY |
|
64 | - */ |
|
65 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
66 | - |
|
67 | - /** |
|
68 | - * IGNORE clause |
|
69 | - */ |
|
70 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * TABLE update |
|
74 | - */ |
|
75 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::TABLE); |
|
76 | - |
|
77 | - /** |
|
78 | - * FIELDS update |
|
79 | - */ |
|
80 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
81 | - |
|
82 | - /** |
|
83 | - * WHERE clause |
|
84 | - */ |
|
85 | - $syntax[] = $this->getWhereSyntax(); |
|
86 | - |
|
87 | - /** |
|
88 | - * ORDER BY clause |
|
89 | - */ |
|
90 | - $syntax[] = $this->getOrderBySyntax(); |
|
91 | - |
|
92 | - /** |
|
93 | - * LIMIT clause |
|
94 | - */ |
|
95 | - $syntax[] = $this->getLimitSyntax(); |
|
96 | - |
|
97 | - $syntax = implode(' ', $syntax); |
|
98 | - |
|
99 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @return array|int|null |
|
105 | - * @throws QueryException |
|
106 | - */ |
|
107 | - public function execute() |
|
108 | - { |
|
109 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
110 | - throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
111 | - |
|
112 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
113 | - } |
|
29 | + use Limit, Where, WhereAndHavingBuilder, Replacement, OrderBy, SetFields, Ignore, DefaultPriority, LowPriority, Utilities; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $statement = self::QUERY_STATEMENT_UPDATE; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * QueryUpdate constructor. |
|
39 | + * @param QueryBuild $queryBuild |
|
40 | + * @param string $table |
|
41 | + */ |
|
42 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
43 | + { |
|
44 | + parent::__construct($queryBuild, $table); |
|
45 | + } |
|
46 | + |
|
47 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
48 | + { |
|
49 | + |
|
50 | + $syntax = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * Explain |
|
54 | + */ |
|
55 | + $syntax[] = $this->getExplainSyntax(); |
|
56 | + |
|
57 | + /** |
|
58 | + * UPDATE statement |
|
59 | + */ |
|
60 | + $syntax[] = $this->statement; |
|
61 | + |
|
62 | + /** |
|
63 | + * PRIORITY |
|
64 | + */ |
|
65 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
66 | + |
|
67 | + /** |
|
68 | + * IGNORE clause |
|
69 | + */ |
|
70 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * TABLE update |
|
74 | + */ |
|
75 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::TABLE); |
|
76 | + |
|
77 | + /** |
|
78 | + * FIELDS update |
|
79 | + */ |
|
80 | + $syntax[] = $this->getSettingFieldsSyntax(); |
|
81 | + |
|
82 | + /** |
|
83 | + * WHERE clause |
|
84 | + */ |
|
85 | + $syntax[] = $this->getWhereSyntax(); |
|
86 | + |
|
87 | + /** |
|
88 | + * ORDER BY clause |
|
89 | + */ |
|
90 | + $syntax[] = $this->getOrderBySyntax(); |
|
91 | + |
|
92 | + /** |
|
93 | + * LIMIT clause |
|
94 | + */ |
|
95 | + $syntax[] = $this->getLimitSyntax(); |
|
96 | + |
|
97 | + $syntax = implode(' ', $syntax); |
|
98 | + |
|
99 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
100 | + |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @return array|int|null |
|
105 | + * @throws QueryException |
|
106 | + */ |
|
107 | + public function execute() |
|
108 | + { |
|
109 | + if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
110 | + throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
111 | + |
|
112 | + return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
113 | + } |
|
114 | 114 | } |
115 | 115 | \ No newline at end of file |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @param QueryBuild $queryBuild |
40 | 40 | * @param string $table |
41 | 41 | */ |
42 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
42 | + public function __construct( QueryBuild $queryBuild, $table = null ) |
|
43 | 43 | { |
44 | - parent::__construct($queryBuild, $table); |
|
44 | + parent::__construct( $queryBuild, $table ); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
47 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
48 | 48 | { |
49 | 49 | |
50 | 50 | $syntax = array(); |
@@ -52,51 +52,51 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Explain |
54 | 54 | */ |
55 | - $syntax[] = $this->getExplainSyntax(); |
|
55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * UPDATE statement |
59 | 59 | */ |
60 | - $syntax[] = $this->statement; |
|
60 | + $syntax[ ] = $this->statement; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * PRIORITY |
64 | 64 | */ |
65 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * IGNORE clause |
69 | 69 | */ |
70 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
70 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * TABLE update |
74 | 74 | */ |
75 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::TABLE); |
|
75 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * FIELDS update |
79 | 79 | */ |
80 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
80 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * WHERE clause |
84 | 84 | */ |
85 | - $syntax[] = $this->getWhereSyntax(); |
|
85 | + $syntax[ ] = $this->getWhereSyntax(); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * ORDER BY clause |
89 | 89 | */ |
90 | - $syntax[] = $this->getOrderBySyntax(); |
|
90 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * LIMIT clause |
94 | 94 | */ |
95 | - $syntax[] = $this->getLimitSyntax(); |
|
95 | + $syntax[ ] = $this->getLimitSyntax(); |
|
96 | 96 | |
97 | - $syntax = implode(' ', $syntax); |
|
97 | + $syntax = implode( ' ', $syntax ); |
|
98 | 98 | |
99 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
99 | + return $this->getSyntaxReplace( $syntax, $replacement ); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function execute() |
108 | 108 | { |
109 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
110 | - throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
109 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
110 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
111 | 111 | |
112 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
112 | + return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | \ No newline at end of file |
@@ -106,8 +106,9 @@ |
||
106 | 106 | */ |
107 | 107 | public function execute() |
108 | 108 | { |
109 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
110 | - throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
109 | + if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) { |
|
110 | + throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
111 | + } |
|
111 | 112 | |
112 | 113 | return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
113 | 114 | } |
@@ -23,81 +23,81 @@ |
||
23 | 23 | class QueryInsert extends QueryStatement implements QueryStatementInterface |
24 | 24 | { |
25 | 25 | |
26 | - use Replacement, SetFields, Ignore, DefaultPriority, LowPriority, HighPriority, Utilities; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $statement = self::QUERY_STATEMENT_INSERT; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * QueryInsert constructor. |
|
36 | - * @param QueryBuild $queryBuild |
|
37 | - * @param string $table |
|
38 | - */ |
|
39 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | - { |
|
41 | - parent::__construct($queryBuild, $table); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @return QueryInsertMultiple |
|
46 | - */ |
|
47 | - public function multiple() |
|
48 | - { |
|
49 | - return new QueryInsertMultiple($this->queryBuild, $this->queryStructure->getElement(QueryStructure::TABLE)); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param bool|int $replacement |
|
54 | - * @return mixed|string |
|
55 | - */ |
|
56 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
57 | - { |
|
58 | - $syntax = array(); |
|
59 | - |
|
60 | - /** |
|
61 | - * Explain |
|
62 | - */ |
|
63 | - $syntax[] = $this->getExplainSyntax(); |
|
64 | - |
|
65 | - /** |
|
66 | - * UPDATE statement |
|
67 | - */ |
|
68 | - $syntax[] = $this->statement; |
|
69 | - |
|
70 | - /** |
|
71 | - * PRIORITY |
|
72 | - */ |
|
73 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
74 | - |
|
75 | - /** |
|
76 | - * IGNORE clause |
|
77 | - */ |
|
78 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
79 | - |
|
80 | - /** |
|
81 | - * INTO table |
|
82 | - */ |
|
83 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
84 | - |
|
85 | - /** |
|
86 | - * FIELDS update |
|
87 | - */ |
|
88 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
89 | - |
|
90 | - $syntax = implode(' ', $syntax); |
|
91 | - |
|
92 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - public function execute() |
|
98 | - { |
|
99 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
100 | - } |
|
26 | + use Replacement, SetFields, Ignore, DefaultPriority, LowPriority, HighPriority, Utilities; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $statement = self::QUERY_STATEMENT_INSERT; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * QueryInsert constructor. |
|
36 | + * @param QueryBuild $queryBuild |
|
37 | + * @param string $table |
|
38 | + */ |
|
39 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | + { |
|
41 | + parent::__construct($queryBuild, $table); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @return QueryInsertMultiple |
|
46 | + */ |
|
47 | + public function multiple() |
|
48 | + { |
|
49 | + return new QueryInsertMultiple($this->queryBuild, $this->queryStructure->getElement(QueryStructure::TABLE)); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param bool|int $replacement |
|
54 | + * @return mixed|string |
|
55 | + */ |
|
56 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
57 | + { |
|
58 | + $syntax = array(); |
|
59 | + |
|
60 | + /** |
|
61 | + * Explain |
|
62 | + */ |
|
63 | + $syntax[] = $this->getExplainSyntax(); |
|
64 | + |
|
65 | + /** |
|
66 | + * UPDATE statement |
|
67 | + */ |
|
68 | + $syntax[] = $this->statement; |
|
69 | + |
|
70 | + /** |
|
71 | + * PRIORITY |
|
72 | + */ |
|
73 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
74 | + |
|
75 | + /** |
|
76 | + * IGNORE clause |
|
77 | + */ |
|
78 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
79 | + |
|
80 | + /** |
|
81 | + * INTO table |
|
82 | + */ |
|
83 | + $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
84 | + |
|
85 | + /** |
|
86 | + * FIELDS update |
|
87 | + */ |
|
88 | + $syntax[] = $this->getSettingFieldsSyntax(); |
|
89 | + |
|
90 | + $syntax = implode(' ', $syntax); |
|
91 | + |
|
92 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + public function execute() |
|
98 | + { |
|
99 | + return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @param QueryBuild $queryBuild |
37 | 37 | * @param string $table |
38 | 38 | */ |
39 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
39 | + public function __construct( QueryBuild $queryBuild, $table = null ) |
|
40 | 40 | { |
41 | - parent::__construct($queryBuild, $table); |
|
41 | + parent::__construct( $queryBuild, $table ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function multiple() |
48 | 48 | { |
49 | - return new QueryInsertMultiple($this->queryBuild, $this->queryStructure->getElement(QueryStructure::TABLE)); |
|
49 | + return new QueryInsertMultiple( $this->queryBuild, $this->queryStructure->getElement( QueryStructure::TABLE ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param bool|int $replacement |
54 | 54 | * @return mixed|string |
55 | 55 | */ |
56 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
56 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
57 | 57 | { |
58 | 58 | $syntax = array(); |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Explain |
62 | 62 | */ |
63 | - $syntax[] = $this->getExplainSyntax(); |
|
63 | + $syntax[ ] = $this->getExplainSyntax(); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * UPDATE statement |
67 | 67 | */ |
68 | - $syntax[] = $this->statement; |
|
68 | + $syntax[ ] = $this->statement; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * PRIORITY |
72 | 72 | */ |
73 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
73 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * IGNORE clause |
77 | 77 | */ |
78 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
78 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * INTO table |
82 | 82 | */ |
83 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
83 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * FIELDS update |
87 | 87 | */ |
88 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
88 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
89 | 89 | |
90 | - $syntax = implode(' ', $syntax); |
|
90 | + $syntax = implode( ' ', $syntax ); |
|
91 | 91 | |
92 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
92 | + return $this->getSyntaxReplace( $syntax, $replacement ); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function execute() |
98 | 98 | { |
99 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
99 | + return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 |
@@ -23,67 +23,67 @@ |
||
23 | 23 | class QueryInsertMultiple extends QueryStatement implements QueryStatementInterface |
24 | 24 | { |
25 | 25 | |
26 | - use InsertMultiple, Replacement, Ignore, DefaultPriority, LowPriority, HighPriority, Utilities; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $statement = self::QUERY_STATEMENT_INSERT; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * QueryInsert constructor. |
|
36 | - * @param QueryBuild $queryBuild |
|
37 | - * @param string $table |
|
38 | - */ |
|
39 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | - { |
|
41 | - parent::__construct($queryBuild, $table); |
|
42 | - $this->queryStructure->setElement(QueryStructure::FIELDS, array()); |
|
43 | - } |
|
44 | - |
|
45 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
46 | - { |
|
47 | - $syntax = array(); |
|
48 | - |
|
49 | - /** |
|
50 | - * Explain |
|
51 | - */ |
|
52 | - $syntax[] = $this->getExplainSyntax(); |
|
53 | - |
|
54 | - /** |
|
55 | - * UPDATE statement |
|
56 | - */ |
|
57 | - $syntax[] = $this->statement; |
|
58 | - |
|
59 | - /** |
|
60 | - * PRIORITY |
|
61 | - */ |
|
62 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
63 | - |
|
64 | - /** |
|
65 | - * IGNORE clause |
|
66 | - */ |
|
67 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
68 | - |
|
69 | - /** |
|
70 | - * INTO table |
|
71 | - */ |
|
72 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
73 | - |
|
74 | - /** |
|
75 | - * FIELDS update |
|
76 | - */ |
|
77 | - $syntax[] = $this->getInsertMultipleRowsSyntax(); |
|
78 | - |
|
79 | - $syntax = implode(' ', $syntax); |
|
80 | - |
|
81 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - public function execute() |
|
86 | - { |
|
87 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
88 | - } |
|
26 | + use InsertMultiple, Replacement, Ignore, DefaultPriority, LowPriority, HighPriority, Utilities; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $statement = self::QUERY_STATEMENT_INSERT; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * QueryInsert constructor. |
|
36 | + * @param QueryBuild $queryBuild |
|
37 | + * @param string $table |
|
38 | + */ |
|
39 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | + { |
|
41 | + parent::__construct($queryBuild, $table); |
|
42 | + $this->queryStructure->setElement(QueryStructure::FIELDS, array()); |
|
43 | + } |
|
44 | + |
|
45 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
46 | + { |
|
47 | + $syntax = array(); |
|
48 | + |
|
49 | + /** |
|
50 | + * Explain |
|
51 | + */ |
|
52 | + $syntax[] = $this->getExplainSyntax(); |
|
53 | + |
|
54 | + /** |
|
55 | + * UPDATE statement |
|
56 | + */ |
|
57 | + $syntax[] = $this->statement; |
|
58 | + |
|
59 | + /** |
|
60 | + * PRIORITY |
|
61 | + */ |
|
62 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
63 | + |
|
64 | + /** |
|
65 | + * IGNORE clause |
|
66 | + */ |
|
67 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
68 | + |
|
69 | + /** |
|
70 | + * INTO table |
|
71 | + */ |
|
72 | + $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
73 | + |
|
74 | + /** |
|
75 | + * FIELDS update |
|
76 | + */ |
|
77 | + $syntax[] = $this->getInsertMultipleRowsSyntax(); |
|
78 | + |
|
79 | + $syntax = implode(' ', $syntax); |
|
80 | + |
|
81 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
82 | + |
|
83 | + } |
|
84 | + |
|
85 | + public function execute() |
|
86 | + { |
|
87 | + return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -36,54 +36,54 @@ |
||
36 | 36 | * @param QueryBuild $queryBuild |
37 | 37 | * @param string $table |
38 | 38 | */ |
39 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
39 | + public function __construct( QueryBuild $queryBuild, $table = null ) |
|
40 | 40 | { |
41 | - parent::__construct($queryBuild, $table); |
|
42 | - $this->queryStructure->setElement(QueryStructure::FIELDS, array()); |
|
41 | + parent::__construct( $queryBuild, $table ); |
|
42 | + $this->queryStructure->setElement( QueryStructure::FIELDS, array() ); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
45 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
46 | 46 | { |
47 | 47 | $syntax = array(); |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Explain |
51 | 51 | */ |
52 | - $syntax[] = $this->getExplainSyntax(); |
|
52 | + $syntax[ ] = $this->getExplainSyntax(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * UPDATE statement |
56 | 56 | */ |
57 | - $syntax[] = $this->statement; |
|
57 | + $syntax[ ] = $this->statement; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * PRIORITY |
61 | 61 | */ |
62 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
62 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * IGNORE clause |
66 | 66 | */ |
67 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::IGNORE) ? 'IGNORE' : ''; |
|
67 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * INTO table |
71 | 71 | */ |
72 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
72 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * FIELDS update |
76 | 76 | */ |
77 | - $syntax[] = $this->getInsertMultipleRowsSyntax(); |
|
77 | + $syntax[ ] = $this->getInsertMultipleRowsSyntax(); |
|
78 | 78 | |
79 | - $syntax = implode(' ', $syntax); |
|
79 | + $syntax = implode( ' ', $syntax ); |
|
80 | 80 | |
81 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
81 | + return $this->getSyntaxReplace( $syntax, $replacement ); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | 85 | public function execute() |
86 | 86 | { |
87 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
87 | + return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -18,71 +18,71 @@ |
||
18 | 18 | abstract class QueryStatement |
19 | 19 | { |
20 | 20 | |
21 | - use Utilities, TableValidation, ColumnValidation; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Statements |
|
26 | - */ |
|
27 | - const QUERY_STATEMENT_SELECT = 'SELECT'; |
|
28 | - const QUERY_STATEMENT_UPDATE = 'UPDATE'; |
|
29 | - const QUERY_STATEMENT_DELETE = 'DELETE'; |
|
30 | - const QUERY_STATEMENT_INSERT = 'INSERT'; |
|
31 | - const QUERY_STATEMENT_CUSTOM = 'CUSTOM'; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $statement; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var QueryBuild |
|
41 | - */ |
|
42 | - protected $queryBuild; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var QueryStructure |
|
46 | - */ |
|
47 | - protected $queryStructure; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - protected $usedInstanceIds = []; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string |
|
56 | - */ |
|
57 | - protected $tablePrefix; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * QueryStatement constructor. |
|
62 | - * @param QueryBuild $queryBuild |
|
63 | - * @param string|QuerySelect $table |
|
64 | - * @throws QueryException |
|
65 | - */ |
|
66 | - public function __construct(QueryBuild $queryBuild, $table = '') |
|
67 | - { |
|
68 | - |
|
69 | - $table = $this->validateTable($table); |
|
70 | - |
|
71 | - $this->queryBuild = $queryBuild; |
|
72 | - $this->queryStructure = new QueryStructure(); |
|
73 | - $this->queryStructure->setElement(QueryStructure::TABLE, $table); |
|
74 | - $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
75 | - $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
76 | - |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @return mixed |
|
81 | - */ |
|
82 | - public function getBindParams() |
|
83 | - { |
|
84 | - return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
85 | - } |
|
21 | + use Utilities, TableValidation, ColumnValidation; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Statements |
|
26 | + */ |
|
27 | + const QUERY_STATEMENT_SELECT = 'SELECT'; |
|
28 | + const QUERY_STATEMENT_UPDATE = 'UPDATE'; |
|
29 | + const QUERY_STATEMENT_DELETE = 'DELETE'; |
|
30 | + const QUERY_STATEMENT_INSERT = 'INSERT'; |
|
31 | + const QUERY_STATEMENT_CUSTOM = 'CUSTOM'; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $statement; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var QueryBuild |
|
41 | + */ |
|
42 | + protected $queryBuild; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var QueryStructure |
|
46 | + */ |
|
47 | + protected $queryStructure; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + protected $usedInstanceIds = []; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string |
|
56 | + */ |
|
57 | + protected $tablePrefix; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * QueryStatement constructor. |
|
62 | + * @param QueryBuild $queryBuild |
|
63 | + * @param string|QuerySelect $table |
|
64 | + * @throws QueryException |
|
65 | + */ |
|
66 | + public function __construct(QueryBuild $queryBuild, $table = '') |
|
67 | + { |
|
68 | + |
|
69 | + $table = $this->validateTable($table); |
|
70 | + |
|
71 | + $this->queryBuild = $queryBuild; |
|
72 | + $this->queryStructure = new QueryStructure(); |
|
73 | + $this->queryStructure->setElement(QueryStructure::TABLE, $table); |
|
74 | + $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
75 | + $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
76 | + |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | + public function getBindParams() |
|
83 | + { |
|
84 | + return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $usedInstanceIds = []; |
|
52 | + protected $usedInstanceIds = [ ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | * @param string|QuerySelect $table |
64 | 64 | * @throws QueryException |
65 | 65 | */ |
66 | - public function __construct(QueryBuild $queryBuild, $table = '') |
|
66 | + public function __construct( QueryBuild $queryBuild, $table = '' ) |
|
67 | 67 | { |
68 | 68 | |
69 | - $table = $this->validateTable($table); |
|
69 | + $table = $this->validateTable( $table ); |
|
70 | 70 | |
71 | 71 | $this->queryBuild = $queryBuild; |
72 | 72 | $this->queryStructure = new QueryStructure(); |
73 | - $this->queryStructure->setElement(QueryStructure::TABLE, $table); |
|
74 | - $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
75 | - $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
73 | + $this->queryStructure->setElement( QueryStructure::TABLE, $table ); |
|
74 | + $this->queryStructure->setElement( QueryStructure::STATEMENT, $this->statement ); |
|
75 | + $this->queryStructure->setElement( QueryStructure::QUERY_TYPE, $this->queryBuild->getType() ); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getBindParams() |
83 | 83 | { |
84 | - return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
84 | + return $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 |
@@ -11,17 +11,17 @@ |
||
11 | 11 | interface QueryStatementInterface |
12 | 12 | { |
13 | 13 | |
14 | - const REPLACEMENT_NONE = 0; |
|
15 | - const REPLACEMENT_VALUES = 1; |
|
14 | + const REPLACEMENT_NONE = 0; |
|
15 | + const REPLACEMENT_VALUES = 1; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param bool $replacement |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function getSyntax($replacement = self::REPLACEMENT_NONE); |
|
17 | + /** |
|
18 | + * @param bool $replacement |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function getSyntax($replacement = self::REPLACEMENT_NONE); |
|
22 | 22 | |
23 | - public function execute(); |
|
23 | + public function execute(); |
|
24 | 24 | |
25 | - public function getBindParams(); |
|
25 | + public function getBindParams(); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @param bool $replacement |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function getSyntax($replacement = self::REPLACEMENT_NONE); |
|
21 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ); |
|
22 | 22 | |
23 | 23 | public function execute(); |
24 | 24 |
@@ -27,81 +27,81 @@ |
||
27 | 27 | class QueryDelete extends QueryStatement implements QueryStatementInterface |
28 | 28 | { |
29 | 29 | |
30 | - use Limit, Where, WhereAndHavingBuilder, Replacement, OrderBy, SetFields, Ignore, DefaultPriority, LowPriority, Utilities; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $statement = self::QUERY_STATEMENT_DELETE; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * QueryDelete constructor. |
|
40 | - * @param QueryBuild $queryBuild |
|
41 | - * @param string $table |
|
42 | - */ |
|
43 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
44 | - { |
|
45 | - parent::__construct($queryBuild, $table); |
|
46 | - } |
|
47 | - |
|
48 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
49 | - { |
|
50 | - $syntax = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * Explain |
|
54 | - */ |
|
55 | - $syntax[] = $this->getExplainSyntax(); |
|
56 | - |
|
57 | - /** |
|
58 | - * UPDATE statement |
|
59 | - */ |
|
60 | - $syntax[] = $this->statement; |
|
61 | - |
|
62 | - /** |
|
63 | - * PRIORITY |
|
64 | - */ |
|
65 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
66 | - |
|
67 | - /** |
|
68 | - * TABLE update |
|
69 | - */ |
|
70 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
71 | - |
|
72 | - /** |
|
73 | - * WHERE clause |
|
74 | - */ |
|
75 | - $syntax[] = $this->getWhereSyntax(); |
|
76 | - |
|
77 | - /** |
|
78 | - * ORDER BY clause |
|
79 | - */ |
|
80 | - $syntax[] = $this->getOrderBySyntax(); |
|
81 | - |
|
82 | - /** |
|
83 | - * LIMIT clause |
|
84 | - */ |
|
85 | - $syntax[] = $this->getLimitSyntax(); |
|
86 | - |
|
87 | - $syntax = implode(' ', $syntax); |
|
88 | - |
|
89 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array|int|null |
|
94 | - * @throws QueryException |
|
95 | - */ |
|
96 | - public function execute() |
|
97 | - { |
|
98 | - |
|
99 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
100 | - throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
101 | - |
|
102 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
103 | - |
|
104 | - } |
|
30 | + use Limit, Where, WhereAndHavingBuilder, Replacement, OrderBy, SetFields, Ignore, DefaultPriority, LowPriority, Utilities; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $statement = self::QUERY_STATEMENT_DELETE; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * QueryDelete constructor. |
|
40 | + * @param QueryBuild $queryBuild |
|
41 | + * @param string $table |
|
42 | + */ |
|
43 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
44 | + { |
|
45 | + parent::__construct($queryBuild, $table); |
|
46 | + } |
|
47 | + |
|
48 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
49 | + { |
|
50 | + $syntax = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * Explain |
|
54 | + */ |
|
55 | + $syntax[] = $this->getExplainSyntax(); |
|
56 | + |
|
57 | + /** |
|
58 | + * UPDATE statement |
|
59 | + */ |
|
60 | + $syntax[] = $this->statement; |
|
61 | + |
|
62 | + /** |
|
63 | + * PRIORITY |
|
64 | + */ |
|
65 | + $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
66 | + |
|
67 | + /** |
|
68 | + * TABLE update |
|
69 | + */ |
|
70 | + $syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
71 | + |
|
72 | + /** |
|
73 | + * WHERE clause |
|
74 | + */ |
|
75 | + $syntax[] = $this->getWhereSyntax(); |
|
76 | + |
|
77 | + /** |
|
78 | + * ORDER BY clause |
|
79 | + */ |
|
80 | + $syntax[] = $this->getOrderBySyntax(); |
|
81 | + |
|
82 | + /** |
|
83 | + * LIMIT clause |
|
84 | + */ |
|
85 | + $syntax[] = $this->getLimitSyntax(); |
|
86 | + |
|
87 | + $syntax = implode(' ', $syntax); |
|
88 | + |
|
89 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array|int|null |
|
94 | + * @throws QueryException |
|
95 | + */ |
|
96 | + public function execute() |
|
97 | + { |
|
98 | + |
|
99 | + if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
100 | + throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
101 | + |
|
102 | + return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
103 | + |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | } |
108 | 108 | \ No newline at end of file |
@@ -40,53 +40,53 @@ discard block |
||
40 | 40 | * @param QueryBuild $queryBuild |
41 | 41 | * @param string $table |
42 | 42 | */ |
43 | - public function __construct(QueryBuild $queryBuild, $table = null) |
|
43 | + public function __construct( QueryBuild $queryBuild, $table = null ) |
|
44 | 44 | { |
45 | - parent::__construct($queryBuild, $table); |
|
45 | + parent::__construct( $queryBuild, $table ); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
48 | + public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
49 | 49 | { |
50 | 50 | $syntax = array(); |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Explain |
54 | 54 | */ |
55 | - $syntax[] = $this->getExplainSyntax(); |
|
55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * UPDATE statement |
59 | 59 | */ |
60 | - $syntax[] = $this->statement; |
|
60 | + $syntax[ ] = $this->statement; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * PRIORITY |
64 | 64 | */ |
65 | - $syntax[] = $this->queryStructure->getElement(QueryStructure::PRIORITY); |
|
65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * TABLE update |
69 | 69 | */ |
70 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement(QueryStructure::TABLE); |
|
70 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * WHERE clause |
74 | 74 | */ |
75 | - $syntax[] = $this->getWhereSyntax(); |
|
75 | + $syntax[ ] = $this->getWhereSyntax(); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * ORDER BY clause |
79 | 79 | */ |
80 | - $syntax[] = $this->getOrderBySyntax(); |
|
80 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * LIMIT clause |
84 | 84 | */ |
85 | - $syntax[] = $this->getLimitSyntax(); |
|
85 | + $syntax[ ] = $this->getLimitSyntax(); |
|
86 | 86 | |
87 | - $syntax = implode(' ', $syntax); |
|
87 | + $syntax = implode( ' ', $syntax ); |
|
88 | 88 | |
89 | - return $this->getSyntaxReplace($syntax, $replacement); |
|
89 | + return $this->getSyntaxReplace( $syntax, $replacement ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | public function execute() |
97 | 97 | { |
98 | 98 | |
99 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
100 | - throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
99 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
100 | + throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
101 | 101 | |
102 | - return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
|
102 | + return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 |
@@ -96,8 +96,9 @@ |
||
96 | 96 | public function execute() |
97 | 97 | { |
98 | 98 | |
99 | - if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) |
|
100 | - throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
99 | + if ($this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && !count($this->queryStructure->getElement(QueryStructure::WHERE))) { |
|
100 | + throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
101 | + } |
|
101 | 102 | |
102 | 103 | return DbService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS)); |
103 | 104 |