Skip to content

Commit e3453ee

Browse files
committed
Simplify the explain code to be more dynamic and simple
1 parent 7f7cdcd commit e3453ee

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

classes/QueryRewrite.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,16 @@ public function toSelect() {
9494
}
9595

9696
public function asExplain() {
97-
switch ($this->type) {
98-
case self::SELECT:
99-
case self::UNION:
100-
$sql = $this->sql;
101-
break;
102-
case self::DELETE:
103-
case self::DELETEMULTI:
104-
case self::UPDATE:
105-
case self::INSERTSELECT:
106-
$sql = $this->toSelect();
107-
break;
108-
default:
109-
return null;
110-
}
97+
$sql = $this->toSelect();
98+
if (is_null($sql))
99+
return null;
111100
return "EXPLAIN $sql";
112101
}
113102

114103
public function asExtendedExplain() {
115-
$sql = $this->asExplain();
104+
$sql = $this->toSelect();
116105
if (is_null($sql))
117106
return null;
118-
$sql = preg_replace('/^EXPLAIN /i', 'EXPLAIN EXTENDED ', $sql);
119-
return $sql;
107+
return "EXPLAIN EXTENDED $sql";
120108
}
121109
}

0 commit comments

Comments
 (0)