web-base/Core/Driver/SQL/Condition/Exists.class.php

23 lines
481 B
PHP
Raw Normal View History

2021-11-11 14:25:26 +01:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Driver\SQL\Condition;
2021-11-11 14:25:26 +01:00
2022-11-18 18:06:46 +01:00
use Core\Driver\SQL\Query\Select;
use Core\Driver\SQL\SQL;
class Exists extends Condition {
2021-11-11 14:25:26 +01:00
private Select $subQuery;
public function __construct(Select $subQuery) {
2021-11-11 14:25:26 +01:00
$this->subQuery = $subQuery;
}
public function getSubQuery(): Select {
2021-11-11 14:25:26 +01:00
return $this->subQuery;
}
function getExpression(SQL $sql, array &$params): string {
return "EXISTS(" .$this->getSubQuery()->build($params) . ")";
}
2021-11-11 14:25:26 +01:00
}