| Server IP : 172.67.216.113 / Your IP : 104.23.243.32 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/2388321/cwd/3rdparty/phpMyAdmin/vendor/phpmyadmin/sql-parser/src/Components/ |
Upload File : |
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
use PhpMyAdmin\SqlParser\Component;
use PhpMyAdmin\SqlParser\Parser;
use RuntimeException;
/**
* `WITH` keyword builder.
*
* @final
*/
final class WithKeyword extends Component
{
/** @var string */
public $name;
/** @var ArrayObj[] */
public $columns = [];
/** @var Parser|null */
public $statement;
public function __construct(string $name)
{
$this->name = $name;
}
/**
* @param WithKeyword $component
* @param array<string, mixed> $options
*
* @return string
*/
public static function build($component, array $options = [])
{
if (! $component instanceof WithKeyword) {
throw new RuntimeException('Can not build a component that is not a WithKeyword');
}
if (! isset($component->statement)) {
throw new RuntimeException('No statement inside WITH');
}
$str = $component->name;
if ($component->columns) {
$str .= ArrayObj::build($component->columns);
}
$str .= ' AS (';
foreach ($component->statement->statements as $statement) {
$str .= $statement->build();
}
$str .= ')';
return $str;
}
}