mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 05:14:25 +02:00
parent
8e88864f4a
commit
ae78613443
@ -23,6 +23,15 @@ class DbQuery extends SimpleQuery
|
|||||||
*/
|
*/
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the query is a sub query
|
||||||
|
*
|
||||||
|
* Sub queries are automatically wrapped in parentheses
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $isSubQuery = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select query
|
* Select query
|
||||||
*
|
*
|
||||||
@ -71,6 +80,27 @@ class DbQuery extends SimpleQuery
|
|||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not the query is a sub query
|
||||||
|
*/
|
||||||
|
public function getIsSubQuery()
|
||||||
|
{
|
||||||
|
return $this->isSubQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not the query is a sub query
|
||||||
|
*
|
||||||
|
* @param bool $isSubQuery
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIsSubQuery($isSubQuery = true)
|
||||||
|
{
|
||||||
|
$this->isSubQuery = (bool) $isSubQuery;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setUseSubqueryCount($useSubqueryCount = true)
|
public function setUseSubqueryCount($useSubqueryCount = true)
|
||||||
{
|
{
|
||||||
$this->useSubqueryCount = $useSubqueryCount;
|
$this->useSubqueryCount = $useSubqueryCount;
|
||||||
@ -331,7 +361,8 @@ class DbQuery extends SimpleQuery
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return (string) $this->getSelectQuery();
|
$select = (string) $this->getSelectQuery();
|
||||||
|
return $this->getIsSubQuery() ? ('(' . $select . ')') : $select;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user