summaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/QueryBuilder')
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php5
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php62
2 files changed, 34 insertions, 33 deletions
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
index 3b67661c8b0..46bb536dfd2 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
@@ -72,9 +72,10 @@ class FunctionBuilder implements IFunctionBuilder {
return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y));
}
- public function count($count, $alias = '') {
+ public function count($count = '', $alias = '') {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
- return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias);
+ $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count);
+ return new QueryFunction('COUNT(' . $quotedName . ')' . $alias);
}
public function max($field) {
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index 25d59fb7d7d..bff38c0c8d6 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -245,7 +245,7 @@ class QueryBuilder implements IQueryBuilder {
* @param mixed $value The parameter value.
* @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function setParameter($key, $value, $type = null) {
$this->queryBuilder->setParameter($key, $value, $type);
@@ -270,7 +270,7 @@ class QueryBuilder implements IQueryBuilder {
* @param array $params The query parameters to set.
* @param array $types The query parameters types to set.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function setParameters(array $params, array $types = array()) {
$this->queryBuilder->setParameters($params, $types);
@@ -323,7 +323,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param integer $firstResult The first result to return.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function setFirstResult($firstResult) {
$this->queryBuilder->setFirstResult($firstResult);
@@ -350,7 +350,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param integer $maxResults The maximum number of results to retrieve.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function setMaxResults($maxResults) {
$this->queryBuilder->setMaxResults($maxResults);
@@ -381,7 +381,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$selects The selection expressions.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * '@return $this This QueryBuilder instance.
*/
public function select(...$selects) {
if (count($selects) === 1 && is_array($selects[0])) {
@@ -408,7 +408,7 @@ class QueryBuilder implements IQueryBuilder {
* @param mixed $select The selection expressions.
* @param string $alias The column alias used in the constructed query.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function selectAlias($select, $alias) {
@@ -430,7 +430,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed $select The selection expressions.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function selectDistinct($select) {
@@ -454,7 +454,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$selects The selection expression.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function addSelect(...$selects) {
if (count($selects) === 1 && is_array($selects[0])) {
@@ -482,7 +482,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $delete The table whose rows are subject to the deletion.
* @param string $alias The table alias used in the constructed query.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function delete($delete = null, $alias = null) {
$this->queryBuilder->delete(
@@ -507,7 +507,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $update The table whose rows are subject to the update.
* @param string $alias The table alias used in the constructed query.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function update($update = null, $alias = null) {
$this->queryBuilder->update(
@@ -535,7 +535,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param string $insert The table into which the rows should be inserted.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function insert($insert = null) {
$this->queryBuilder->insert(
@@ -560,7 +560,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $from The table.
* @param string|null $alias The alias of the table.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function from($from, $alias = null) {
$this->queryBuilder->from(
@@ -586,7 +586,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $alias The alias of the join table.
* @param string $condition The condition for the join.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function join($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->join(
@@ -614,7 +614,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $alias The alias of the join table.
* @param string $condition The condition for the join.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function innerJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->innerJoin(
@@ -642,7 +642,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $alias The alias of the join table.
* @param string $condition The condition for the join.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function leftJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->leftJoin(
@@ -670,7 +670,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $alias The alias of the join table.
* @param string $condition The condition for the join.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function rightJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->rightJoin(
@@ -696,7 +696,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $key The column to set.
* @param string $value The value, expression, placeholder, etc.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function set($key, $value) {
$this->queryBuilder->set(
@@ -731,7 +731,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$predicates The restriction predicates.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function where(...$predicates) {
call_user_func_array(
@@ -756,7 +756,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$where The query restrictions.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*
* @see where()
*/
@@ -783,7 +783,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$where The WHERE statement.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*
* @see where()
*/
@@ -809,7 +809,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$groupBys The grouping expression.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function groupBy(...$groupBys) {
if (count($groupBys) === 1 && is_array($groupBys[0])) {
@@ -837,7 +837,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$groupBy The grouping expression.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function addGroupBy(...$groupBys) {
if (count($groupBys) === 1 && is_array($groupBys[0])) {
@@ -869,7 +869,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $column The column into which the value should be inserted.
* @param string $value The value that should be inserted into the column.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function setValue($column, $value) {
$this->queryBuilder->setValue(
@@ -897,7 +897,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param array $values The values to specify for the insert query indexed by column names.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function values(array $values) {
$quotedValues = [];
@@ -916,7 +916,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$having The restriction over the groups.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function having(...$having) {
call_user_func_array(
@@ -933,7 +933,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$having The restriction to append.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function andHaving(...$having) {
call_user_func_array(
@@ -950,7 +950,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param mixed ...$having The restriction to add.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function orHaving(...$having) {
call_user_func_array(
@@ -968,7 +968,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $sort The ordering expression.
* @param string $order The ordering direction.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function orderBy($sort, $order = null) {
$this->queryBuilder->orderBy(
@@ -985,7 +985,7 @@ class QueryBuilder implements IQueryBuilder {
* @param string $sort The ordering expression.
* @param string $order The ordering direction.
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function addOrderBy($sort, $order = null) {
$this->queryBuilder->addOrderBy(
@@ -1021,7 +1021,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param array|null $queryPartNames
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function resetQueryParts($queryPartNames = null) {
$this->queryBuilder->resetQueryParts($queryPartNames);
@@ -1034,7 +1034,7 @@ class QueryBuilder implements IQueryBuilder {
*
* @param string $queryPartName
*
- * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @return $this This QueryBuilder instance.
*/
public function resetQueryPart($queryPartName) {
$this->queryBuilder->resetQueryPart($queryPartName);