* @copyright 2010-2014 Justin Swanhart and André Rothe * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version SVN: $Id$ * */ namespace PHPSQLParser\builders; use PHPSQLParser\utils\ExpressionType; /** * This class implements the builder for the temporary table name and join options. * 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 TempTableBuilder implements Builder { protected function buildAlias($parsed) { $builder = new AliasBuilder(); return $builder->build($parsed); } protected function buildJoin($parsed) { $builder = new JoinBuilder(); return $builder->build($parsed); } protected function buildRefType($parsed) { $builder = new RefTypeBuilder(); return $builder->build($parsed); } protected function buildRefClause($parsed) { $builder = new RefClauseBuilder(); return $builder->build($parsed); } public function build(array $parsed, $index = 0) { if ($parsed['expr_type'] !== ExpressionType::TEMPORARY_TABLE) { return ''; } $sql = $parsed['table']; $sql .= $this->buildAlias($parsed); if ($index !== 0) { $sql = $this->buildJoin($parsed['join_type']) . $sql; $sql .= $this->buildRefType($parsed['ref_type']); $sql .= $parsed['ref_clause'] === false ? '' : $this->buildRefClause($parsed['ref_clause']); } return $sql; } } ?>