phpOMS/DataStorage/Database/Query/Where.php
Dennis Eichhorn 32d6eafaba
Some checks failed
CI / general_module_workflow_php (push) Has been cancelled
fix version and bugs
2024-05-21 00:09:22 +02:00

57 lines
1.2 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package phpOMS\DataStorage\Database\Query
* @copyright Dennis Eichhorn
* @license OMS License 2.2
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\DataStorage\Database\Query;
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
/**
* Database query builder.
*
* @package phpOMS\DataStorage\Database\Query
* @license OMS License 2.2
* @link https://jingga.app
* @since 1.0.0
*/
class Where extends Builder
{
/**
* Constructor.
*
* @param ConnectionAbstract $connection Database connection
*
* @since 1.0.0
*/
public function __construct(ConnectionAbstract $connection)
{
parent::__construct($connection);
$this->type = QueryType::SELECT;
}
/**
* {@inheritdoc}
*/
public function toSql() : string
{
$query = $this->grammar->compileWheres($this, $this->wheres);
$query = \str_starts_with($query, 'WHERE ') ? \substr($query, 6) : $query;
if (self::$log) {
\phpOMS\Log\FileLogger::getInstance()->debug($query);
}
return $query;
}
}