Skip to content

Commit f871af4

Browse files
author
Nuno Chaves
authored
Update QueryBuilder.php
1 parent 70fe173 commit f871af4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/QueryBuilder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,24 @@ public function limit($limit)
114114
public function params($params)
115115
{
116116
$this->params = $params;
117-
return $this;
117+
return $params;
118118
}
119119

120120

121121
/**
122122
* @return $this
123123
*/
124-
public function find()
124+
public function findAll()
125125
{
126126
$this->response = null;
127-
$this->multipleResults = false;
127+
$this->multipleResults = true;
128128

129+
$limit = $this->limit != null ? "top ".(int)$this->limit : "";
129130
$fields = !empty($this->fields) ? $this->fields : '*';
130131
$where = $this->where != "" ? "where {$this->where}" : "";
131132
$order = $this->order != "" ? "order by {$this->order}" : "";
132133

133-
$query = "SELECT top 1 {$fields} FROM {$this->collection} {$this->join} {$where} {$order}";
134+
$query = "SELECT {$limit} {$fields} FROM {$this->collection} {$this->join} {$where} {$order}";
134135

135136
$col = $this->connection->selectCollection($this->collection);
136137
$this->response = $col->query($query, $this->params);
@@ -142,17 +143,16 @@ public function find()
142143
/**
143144
* @return $this
144145
*/
145-
public function findAll()
146+
public function find()
146147
{
147148
$this->response = null;
148-
$this->multipleResults = true;
149+
$this->multipleResults = false;
149150

150-
$limit = $this->limit != null ? "top ".(int)$this->limit : "";
151151
$fields = !empty($this->fields) ? $this->fields : '*';
152152
$where = $this->where != "" ? "where {$this->where}" : "";
153153
$order = $this->order != "" ? "order by {$this->order}" : "";
154154

155-
$query = "SELECT {$limit} {$fields} FROM {$this->collection} {$this->join} {$where} {$order}";
155+
$query = "SELECT top 1 {$fields} FROM {$this->collection} {$this->join} {$where} {$order}";
156156

157157
$col = $this->connection->selectCollection($this->collection);
158158
$this->response = $col->query($query, $this->params);

0 commit comments

Comments
 (0)