* @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; /** * This class implements the builder for the [TRUNCATE] 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 TruncateBuilder implements Builder { public function build(array $parsed) { $sql = "TRUNCATE TABLE "; $right = -1; // works for one table only $parsed['tables'] = array($parsed['TABLE']['base_expr']); if ($parsed['tables'] !== false) { foreach ($parsed['tables'] as $k => $v) { $sql .= $v . ", "; $right = -2; } } return substr($sql, 0, $right); } } ?>