* @copyright 2010-2014 Justin Swanhart and André Rothe * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version SVN: $Id: ShowBuilder.php 830 2013-12-18 09:35:42Z phosco@gmx.de $ * */ require_once dirname(__FILE__) . '/../exceptions/UnableToCreateSQLException.php'; require_once dirname(__FILE__) . '/ReservedBuilder.php'; require_once dirname(__FILE__) . '/ConstantBuilder.php'; require_once dirname(__FILE__) . '/EngineBuilder.php'; require_once dirname(__FILE__) . '/FunctionBuilder.php'; require_once dirname(__FILE__) . '/ProcedureBuilder.php'; require_once dirname(__FILE__) . '/DatabaseBuilder.php'; require_once dirname(__FILE__) . '/TableBuilder.php'; /** * This class implements the builder for the SHOW statement. * You can overwrite all functions to achieve another handling. * * @author André Rothe * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * */ class ShowBuilder { protected function buildTable($parsed, $delim) { $builder = new TableBuilder(); return $builder->build($parsed, $delim); } protected function buildFunction($parsed) { $builder = new FunctionBuilder(); return $builder->build($parsed); } protected function buildProcedure($parsed) { $builder = new ProcedureBuilder(); return $builder->build($parsed); } protected function buildDatabase($parsed) { $builder = new DatabaseBuilder(); return $builder->build($parsed); } protected function buildEngine($parsed) { $builder = new EngineBuilder(); return $builder->build($parsed); } protected function buildConstant($parsed) { $builder = new ConstantBuilder(); return $builder->build($parsed); } protected function buildReserved($parsed) { $builder = new ReservedBuilder(); return $builder->build($parsed); } public function build($parsed) { $show = $parsed['SHOW']; $sql = ""; foreach ($show as $k => $v) { $len = strlen($sql); $sql .= $this->buildReserved($v); $sql .= $this->buildConstant($v); $sql .= $this->buildEngine($v); $sql .= $this->buildDatabase($v); $sql .= $this->buildProcedure($v); $sql .= $this->buildFunction($v); $sql .= $this->buildTable($v, 0); if ($len == strlen($sql)) { throw new UnableToCreateSQLException('SHOW', $k, $v, 'expr_type'); } $sql .= " "; } $sql = substr($sql, 0, -1); return "SHOW " . $sql; } } ?>