* @copyright 2010-2014 Justin Swanhart and André Rothe * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version SVN: $Id: CreateBuilder.php 833 2013-12-18 10:13:59Z phosco@gmx.de $ * */ require_once dirname(__FILE__) . '/../utils/ExpressionType.php'; require_once dirname(__FILE__) . '/CreateTableBuilder.php'; require_once dirname(__FILE__) . '/SubTreeBuilder.php'; /** * This class implements the builder for the [CREATE] part. 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 CreateBuilder { protected function buildCreateTable($parsed) { $builder = new CreateTableBuilder(); return $builder->build($parsed); } protected function buildSubTree($parsed) { $builder = new SubTreeBuilder(); return $builder->build($parsed); } public function build($parsed) { $create = $parsed['CREATE']; $sql = $this->buildSubTree($create); if (($create['expr_type'] === ExpressionType::TABLE) || ($create['expr_type'] === ExpressionType::TEMPORARY_TABLE)) { $sql .= " " . $this->buildCreateTable($parsed['TABLE']); } // TODO: add more expr_types here (like VIEW), if available return "CREATE " . $sql; } } ?>