@@ -43,8 +43,8 @@ class ExplainStatement extends Statement
4343
4444 /**
4545 * The statement alias, could be any of the following:
46- * - EXPLAIN/DESC/ DESCRIBE
47- * - EXPLAIN/DESC/ DESCRIBE ANALYZE
46+ * - { EXPLAIN | DESCRIBE | DESC}
47+ * - { EXPLAIN | DESCRIBE | DESC} ANALYZE
4848 * - ANALYZE
4949 *
5050 * @var string
@@ -89,8 +89,8 @@ public function parse(Parser $parser, TokensList $list)
8989 /**
9090 * To Differentiate between ANALYZE / EXPLAIN / EXPLAIN ANALYZE
9191 * 0 -> ANALYZE ( used by mariaDB https://mariadb.com/kb/en/analyze-statement)
92- * 1 -> EXPLAIN / DESC / DESCRIBE
93- * 2 -> EXPLAIN / DESC / DESCRIBE [ ANALYZE]
92+ * 1 -> { EXPLAIN | DESCRIBE | DESC}
93+ * 2 -> { EXPLAIN | DESCRIBE | DESC} ANALYZE
9494 */
9595 $ miniState = 0 ;
9696
@@ -184,17 +184,20 @@ public function parse(Parser $parser, TokensList $list)
184184
185185 public function build (): string
186186 {
187- $ str = $ this ->statemenetAlias . ' ' ;
187+ $ str = $ this ->statemenetAlias ;
188188
189- $ str .= OptionsArray::build ($ this ->options );
189+ if (count ($ this ->options ->options )) {
190+ $ str .= ' ' ;
191+ }
192+
193+ $ str .= OptionsArray::build ($ this ->options ) . ' ' ;
190194
191195 if ($ this ->bodyParser ) {
192196 foreach ($ this ->bodyParser ->statements as $ statement ) {
193197 $ str .= $ statement ->build ();
194198 }
195199 } elseif ($ this ->connectionId ) {
196- $ str .= 'FOR CONNECTION ' ;
197- $ str .= $ this ->connectionId ;
200+ $ str .= 'FOR CONNECTION ' . $ this ->connectionId ;
198201 } elseif ($ this ->explainedTable ) {
199202 $ str .= $ this ->explainedTable ;
200203 }
0 commit comments