41 lines
830 B
PHP
41 lines
830 B
PHP
<?php
|
|
|
|
namespace Ulmus\Query\Sqlite;
|
|
|
|
class Pragma extends \Ulmus\Query\Fragment {
|
|
|
|
const SQL_TOKEN = "PRAGMA %s%s";
|
|
|
|
public int $order = 15;
|
|
|
|
public /* object|string */ $pragma;
|
|
|
|
public $value;
|
|
|
|
public bool $callable;
|
|
|
|
public function set(/* object|Stringable */ $pragma, /* ? mixed */ $value = null, bool $callable = false) : self
|
|
{
|
|
$this->pragma = $pragma;
|
|
|
|
if ($value) {
|
|
$this->value = $value;
|
|
}
|
|
|
|
$this->callable = $callable;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function render() : string
|
|
{
|
|
if ( isset($this->value) ) {
|
|
$value = sprintf($this->callable ? " (%s)" : "=%s", $this->value);
|
|
}
|
|
|
|
return $this->renderSegments([
|
|
sprintf(static::SQL_TOKEN, $this->pragma, $value ?? "")
|
|
]);
|
|
}
|
|
}
|