ulmus/src/Query/Show.php

46 lines
919 B
PHP

<?php
namespace Ulmus\Query;
class Show extends Fragment {
public int $order = -100;
const SQL_TOKEN = "SHOW";
const SQL_TOKEN_FROM = "FROM";
const SQL_SHOW_DATABASES = "DATABASES";
const SQL_SHOW_TABLES = "TABLES";
public string $show;
public string $from;
public string $in;
public function set(string $show, ? string $from = null, ? string $in = null) : self
{
$this->show = $show;
if ( $from !== null ) {
$this->from = $from;
}
if ( $in !== null ) {
$this->in = $in;
}
return $this;
}
public function render() : string
{
return $this->renderSegments([
static::SQL_TOKEN, $this->show,
] + ( ! empty($this->from) ? [ static::SQL_TOKEN_FROM, $this->from ] : [] ) + ( ! empty($this->in) ? [ static::SQL_TOKEN_IN, $this->in ] : [] ) );
}
}