@@ -13,22 +13,21 @@ class Grammar extends IlluminateGrammar
1313 * @var array
1414 */
1515 protected $ operators = [
16- '= ' , '< ' , '> ' , '<= ' , '>= ' , '!< ' , '!> ' , '<> ' , '!= ' ,
17- 'like ' , 'not like ' , 'between ' , 'ilike ' ,
18- '& ' , '&= ' , '| ' , '|= ' , '^ ' , '^= ' ,
16+ '= ' , '< ' , '> ' , '<= ' , '>= ' , '!< ' , '!> ' , '<> ' , '!= ' , 'like ' , 'not like ' , 'between ' , 'ilike ' , '& ' , '&= ' , '| ' , '|= ' ,
17+ '^ ' , '^= ' ,
1918 ];
2019
2120 /**
2221 * Builder for query.
2322 *
24- * @var \Illuminate\Database\Query\ Builder
23+ * @var Builder
2524 */
2625 protected $ builder ;
2726
2827 /**
2928 * Get the builder.
3029 *
31- * @return \Illuminate\Database\Query\ Builder
30+ * @return Builder
3231 */
3332 public function getBuilder ()
3433 {
@@ -38,7 +37,7 @@ public function getBuilder()
3837 /**
3938 * Compile a select query into SQL.
4039 *
41- * @param \Illuminate\Database\Query\ Builder $query
40+ * @param Builder $query
4241 * @return string
4342 */
4443 public function compileSelect (Builder $ query )
@@ -70,7 +69,7 @@ public function compileSelect(Builder $query)
7069 /**
7170 * Compile an insert statement into SQL.
7271 *
73- * @param \Illuminate\Database\Query\ Builder $query
72+ * @param Builder $query
7473 * @param array $values
7574 * @return string
7675 */
@@ -88,7 +87,7 @@ public function compileInsert(Builder $query, array $values)
8887 return "insert into {$ table } default values " ;
8988 }
9089
91- if (! is_array (reset ($ values ))) {
90+ if (!is_array (reset ($ values ))) {
9291 $ values = [$ values ];
9392 }
9493
@@ -97,17 +96,19 @@ public function compileInsert(Builder $query, array $values)
9796 // We need to build a list of parameter place-holders of values that are bound
9897 // to the query. Each insert should have the exact same number of parameter
9998 // bindings so we will loop through the record and parameterize them all.
100- $ parameters = collect ($ values )->map (function ($ record ) {
101- return 'SELECT ' .$ this ->parameterize ($ record );
102- })->implode (' UNION ALL ' );
99+ $ parameters = collect ($ values )
100+ ->map (function ($ record ) {
101+ return 'SELECT ' .$ this ->parameterize ($ record );
102+ })
103+ ->implode (' UNION ALL ' );
103104
104105 return "insert into $ table ( $ columns) $ parameters " ;
105106 }
106107
107108 /**
108109 * Compile an update statement into SQL.
109110 *
110- * @param \Illuminate\Database\Query\ Builder $query
111+ * @param Builder $query
111112 * @param array $values
112113 * @return string
113114 */
@@ -124,17 +125,14 @@ public function compileUpdate(Builder $query, array $values)
124125
125126 $ where = $ this ->compileWheres ($ query );
126127
127- return trim (
128- isset ($ query ->joins )
129- ? $ this ->compileUpdateWithJoins ($ query , $ table , $ columns , $ where )
130- : $ this ->compileUpdateWithoutJoins ($ query , $ table , $ columns , $ where )
131- );
128+ return trim (isset ($ query ->joins ) ? $ this ->compileUpdateWithJoins ($ query , $ table , $ columns ,
129+ $ where ) : $ this ->compileUpdateWithoutJoins ($ query , $ table , $ columns , $ where ));
132130 }
133131
134132 /**
135133 * Compile a delete statement into SQL.
136134 *
137- * @param \Illuminate\Database\Query\ Builder $query
135+ * @param Builder $query
138136 * @return string
139137 */
140138 public function compileDelete (Builder $ query )
@@ -145,23 +143,43 @@ public function compileDelete(Builder $query)
145143
146144 $ where = $ this ->compileWheres ($ query );
147145
148- return trim (
149- isset ($ query ->joins )
150- ? $ this ->compileDeleteWithJoins ($ query , $ table , $ where )
151- : $ this ->compileDeleteWithoutJoins ($ query , $ table , $ where )
152- );
146+ return trim (isset ($ query ->joins ) ? $ this ->compileDeleteWithJoins ($ query , $ table ,
147+ $ where ) : $ this ->compileDeleteWithoutJoins ($ query , $ table , $ where ));
148+ }
149+
150+ /**
151+ * Compile a truncate table statement into SQL.
152+ *
153+ * @param Builder $query
154+ * @return array
155+ */
156+ public function compileTruncate (Builder $ query )
157+ {
158+ return [
159+ 'truncate table ' .$ this ->wrapTable ($ query ->from ) => [],
160+ ];
161+ }
162+
163+ /**
164+ * Get the format for database stored dates.
165+ *
166+ * @return string
167+ */
168+ public function getDateFormat ()
169+ {
170+ return 'Y-m-d H:i:s.000 ' ;
153171 }
154172
155173 /**
156174 * Compile the "select *" portion of the query.
157175 *
158- * @param \Illuminate\Database\Query\ Builder $query
176+ * @param Builder $query
159177 * @param array $columns
160178 * @return string
161179 */
162180 protected function compileColumns (Builder $ query , $ columns )
163181 {
164- if (! is_null ($ query ->aggregate )) {
182+ if (!is_null ($ query ->aggregate )) {
165183 return ;
166184 }
167185
@@ -181,7 +199,7 @@ protected function compileColumns(Builder $query, $columns)
181199 /**
182200 * Compile the "from" portion of the query.
183201 *
184- * @param \Illuminate\Database\Query\ Builder $query
202+ * @param Builder $query
185203 * @param string $table
186204 * @return string
187205 */
@@ -193,9 +211,8 @@ protected function compileFrom(Builder $query, $table)
193211 return $ from .' ' .$ query ->lock ;
194212 }
195213
196- if (! is_null ($ query ->lock )) {
197- return $ from .' with(rowlock, ' .
198- ($ query ->lock ? 'updlock, ' : '' ).'holdlock) ' ;
214+ if (!is_null ($ query ->lock )) {
215+ return $ from .' with(rowlock, ' .($ query ->lock ? 'updlock, ' : '' ).'holdlock) ' ;
199216 }
200217
201218 return $ from ;
@@ -204,7 +221,7 @@ protected function compileFrom(Builder $query, $table)
204221 /**
205222 * Compile the "limit" portions of the query.
206223 *
207- * @param \Illuminate\Database\Query\ Builder $query
224+ * @param Builder $query
208225 * @param int $limit
209226 * @return string
210227 */
@@ -216,7 +233,7 @@ protected function compileLimit(Builder $query, $limit)
216233 /**
217234 * Compile the "offset" portions of the query.
218235 *
219- * @param \Illuminate\Database\Query\ Builder $query
236+ * @param Builder $query
220237 * @param int $offset
221238 * @return string
222239 */
@@ -229,29 +246,6 @@ protected function compileOffset(Builder $query, $offset)
229246 return '' ;
230247 }
231248
232- /**
233- * Compile a truncate table statement into SQL.
234- *
235- * @param \Illuminate\Database\Query\Builder $query
236- * @return array
237- */
238- public function compileTruncate (Builder $ query )
239- {
240- return [
241- 'truncate table ' .$ this ->wrapTable ($ query ->from ) => [],
242- ];
243- }
244-
245- /**
246- * Get the format for database stored dates.
247- *
248- * @return string
249- */
250- public function getDateFormat ()
251- {
252- return 'Y-m-d H:i:s.000 ' ;
253- }
254-
255249 /**
256250 * Wrap a single string in keyword identifiers.
257251 *
0 commit comments