55
66class SybaseGrammar extends Grammar {
77
8- /**
9- * All of the available clause operators.
10- *
11- * @var array
12- */
8+ /**
9+ * All of the available clause operators.
10+ *
11+ * @var array
12+ */
1313 protected $ operators = array (
14- '= ' , '< ' , '> ' , '<= ' , '>= ' , '!< ' , '!> ' , '<> ' , '!= ' ,
15- 'like ' , 'not like ' , 'between ' , 'ilike ' ,
16- '& ' , '&= ' , '| ' , '|= ' , '^ ' , '^= ' ,
17- );
14+ '= ' , '< ' , '> ' , '<= ' , '>= ' , '!< ' , '!> ' , '<> ' , '!= ' ,
15+ 'like ' , 'not like ' , 'between ' , 'ilike ' ,
16+ '& ' , '&= ' , '| ' , '|= ' , '^ ' , '^= ' ,
17+ );
1818
1919 protected $ Builder ;
2020 public function getBuilder (){
@@ -23,120 +23,120 @@ public function getBuilder(){
2323
2424
2525 /**
26- * Compile a select query into SQL.
27- *
28- * @param \Illuminate\Database\Query\Builder
29- * @return string
30- */
26+ * Compile a select query into SQL.
27+ *
28+ * @param \Illuminate\Database\Query\Builder
29+ * @return string
30+ */
3131
32- public function compileSelect (Builder $ query )
33- {
32+ public function compileSelect (Builder $ query )
33+ {
3434 $ this ->Builder = $ query ;
35- $ components = $ this ->compileComponents ($ query );
36-
37- return $ this ->concatenate ($ components );
38- }
39- /**
40- * Compile the "select *" portion of the query.
41- *
42- * @param \Illuminate\Database\Query\Builder $query
43- * @param array $columns
44- * @return string
45- */
46- protected function compileColumns (Builder $ query , $ columns )
47- {
48- if ( ! is_null ($ query ->aggregate )) return ;
49-
50- $ select = $ query ->distinct ? 'select distinct ' : 'select ' ;
51-
52- // If there is a limit on the query, but not an offset, we will add the top
53- // clause to the query, which serves as a "limit" type clause within the
54- // SQL Server system similar to the limit keywords available in MySQL.
55- if ($ query ->limit > 0 && $ query ->offset <= 0 )
56- {
57- $ select .= 'top ' .$ query ->limit .' ' ;
58- }
59-
60- return $ select .$ this ->columnize ($ columns );
61- }
62-
63- /**
64- * Compile the "from" portion of the query.
65- *
66- * @param \Illuminate\Database\Query\Builder $query
67- * @param string $table
68- * @return string
69- */
70- protected function compileFrom (Builder $ query , $ table )
71- {
72- $ from = parent ::compileFrom ($ query , $ table );
73-
74- if (is_string ($ query ->lock )) return $ from .' ' .$ query ->lock ;
75-
76- if ( ! is_null ($ query ->lock ))
77- {
78- return $ from .' with(rowlock, ' .($ query ->lock ? 'updlock, ' : '' ).'holdlock) ' ;
79- }
80-
81- return $ from ;
82- }
83-
84- /**
85- * Compile the "limit" portions of the query.
86- *
87- * @param \Illuminate\Database\Query\Builder $query
88- * @param int $limit
89- * @return string
90- */
91- protected function compileLimit (Builder $ query , $ limit )
92- {
93- return '' ;
94- }
95-
96- /**
97- * Compile the "offset" portions of the query.
98- *
99- * @param \Illuminate\Database\Query\Builder $query
100- * @param int $offset
101- * @return string
102- */
103- protected function compileOffset (Builder $ query , $ offset )
104- {
105- return '' ;
106- }
107-
108- /**
109- * Compile a truncate table statement into SQL.
110- *
111- * @param \Illuminate\Database\Query\Builder $query
112- * @return array
113- */
114- public function compileTruncate (Builder $ query )
115- {
116- return array ('truncate table ' .$ this ->wrapTable ($ query ->from ) => array ());
117- }
118-
119- /**
120- * Get the format for database stored dates.
121- *
122- * @return string
123- */
124- public function getDateFormat ()
125- {
126- return 'Y-m-d H:i:s.000 ' ;
127- }
128-
129- /**
130- * Wrap a single string in keyword identifiers.
131- *
132- * @param string $value
133- * @return string
134- */
135- protected function wrapValue ($ value )
136- {
137- if ($ value === '* ' ) return $ value ;
138-
139- return '[ ' .str_replace ('] ' , ']] ' , $ value ).'] ' ;
140- }
35+ $ components = $ this ->compileComponents ($ query );
36+
37+ return $ this ->concatenate ($ components );
38+ }
39+ /**
40+ * Compile the "select *" portion of the query.
41+ *
42+ * @param \Illuminate\Database\Query\Builder $query
43+ * @param array $columns
44+ * @return string
45+ */
46+ protected function compileColumns (Builder $ query , $ columns )
47+ {
48+ if ( ! is_null ($ query ->aggregate )) return ;
49+
50+ $ select = $ query ->distinct ? 'select distinct ' : 'select ' ;
51+
52+ // If there is a limit on the query, but not an offset, we will add the top
53+ // clause to the query, which serves as a "limit" type clause within the
54+ // SQL Server system similar to the limit keywords available in MySQL.
55+ if ($ query ->limit > 0 && $ query ->offset <= 0 )
56+ {
57+ $ select .= 'top ' .$ query ->limit .' ' ;
58+ }
59+
60+ return $ select .$ this ->columnize ($ columns );
61+ }
62+
63+ /**
64+ * Compile the "from" portion of the query.
65+ *
66+ * @param \Illuminate\Database\Query\Builder $query
67+ * @param string $table
68+ * @return string
69+ */
70+ protected function compileFrom (Builder $ query , $ table )
71+ {
72+ $ from = parent ::compileFrom ($ query , $ table );
73+
74+ if (is_string ($ query ->lock )) return $ from .' ' .$ query ->lock ;
75+
76+ if ( ! is_null ($ query ->lock ))
77+ {
78+ return $ from .' with(rowlock, ' .($ query ->lock ? 'updlock, ' : '' ).'holdlock) ' ;
79+ }
80+
81+ return $ from ;
82+ }
83+
84+ /**
85+ * Compile the "limit" portions of the query.
86+ *
87+ * @param \Illuminate\Database\Query\Builder $query
88+ * @param int $limit
89+ * @return string
90+ */
91+ protected function compileLimit (Builder $ query , $ limit )
92+ {
93+ return '' ;
94+ }
95+
96+ /**
97+ * Compile the "offset" portions of the query.
98+ *
99+ * @param \Illuminate\Database\Query\Builder $query
100+ * @param int $offset
101+ * @return string
102+ */
103+ protected function compileOffset (Builder $ query , $ offset )
104+ {
105+ return '' ;
106+ }
107+
108+ /**
109+ * Compile a truncate table statement into SQL.
110+ *
111+ * @param \Illuminate\Database\Query\Builder $query
112+ * @return array
113+ */
114+ public function compileTruncate (Builder $ query )
115+ {
116+ return array ('truncate table ' .$ this ->wrapTable ($ query ->from ) => array ());
117+ }
118+
119+ /**
120+ * Get the format for database stored dates.
121+ *
122+ * @return string
123+ */
124+ public function getDateFormat ()
125+ {
126+ return 'Y-m-d H:i:s.000 ' ;
127+ }
128+
129+ /**
130+ * Wrap a single string in keyword identifiers.
131+ *
132+ * @param string $value
133+ * @return string
134+ */
135+ protected function wrapValue ($ value )
136+ {
137+ if ($ value === '* ' ) return $ value ;
138+
139+ return '[ ' .str_replace ('] ' , ']] ' , $ value ).'] ' ;
140+ }
141141
142142}
0 commit comments