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;
|
2023-01-05 22:47:17 +01:00
|
|
|
use Core\Driver\SQL\SQL;
|
|
|
|
|
|
|
|
class Exists extends Condition {
|
2021-11-11 14:25:26 +01:00
|
|
|
|
|
|
|
private Select $subQuery;
|
|
|
|
|
2023-01-05 22:47:17 +01:00
|
|
|
public function __construct(Select $subQuery) {
|
2021-11-11 14:25:26 +01:00
|
|
|
$this->subQuery = $subQuery;
|
|
|
|
}
|
|
|
|
|
2023-01-05 22:47:17 +01:00
|
|
|
public function getSubQuery(): Select {
|
2021-11-11 14:25:26 +01:00
|
|
|
return $this->subQuery;
|
|
|
|
}
|
2023-01-05 22:47:17 +01:00
|
|
|
|
|
|
|
function getExpression(SQL $sql, array &$params): string {
|
|
|
|
return "EXISTS(" .$this->getSubQuery()->build($params) . ")";
|
|
|
|
}
|
2021-11-11 14:25:26 +01:00
|
|
|
}
|