parent
8e88864f4a
commit
ae78613443
|
@ -23,6 +23,15 @@ class DbQuery extends SimpleQuery
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
@ -71,6 +80,27 @@ class DbQuery extends SimpleQuery
|
|||
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)
|
||||
{
|
||||
$this->useSubqueryCount = $useSubqueryCount;
|
||||
|
@ -331,7 +361,8 @@ class DbQuery extends SimpleQuery
|
|||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->getSelectQuery();
|
||||
$select = (string) $this->getSelectQuery();
|
||||
return $this->getIsSubQuery() ? ('(' . $select . ')') : $select;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue