public function testConstructor() { $sql = "SELECT id FROM ips WHERE ip='192.168.0.1' AND type=1 LIMIT 1"; $expectedType = QueryRewrite::SELECT; $expectedSelect = "SELECT id FROM ips WHERE ip='192.168.0.1' AND type=1 LIMIT 1"; $expectedExplain = "EXPLAIN {$expectedSelect}"; $expectedExtendedExplain = "EXPLAIN EXTENDED {$expectedSelect}"; $QRW = new QueryRewrite($sql); $this->assertEquals($expectedType, $QRW->getType()); $this->assertEquals($expectedSelect, $QRW->toSelect()); $this->assertEquals($expectedExplain, $QRW->asExplain()); $this->assertEquals($expectedExtendedExplain, $QRW->asExtendedExplain()); unset($QRW); }
/** * Execute EXPLAIN $query and return the result * @return MySQLi_Result the result handle */ private function explain_query() { $Query = new QueryRewrite($this->query); $explain = $Query->asExplain(); if (is_null($explain)) { return null; } return $this->mysqli->query($explain); }