@@ -114,23 +114,24 @@ public function limit($limit)
114
114
public function params ($ params )
115
115
{
116
116
$ this ->params = $ params ;
117
- return $ this ;
117
+ return $ params ;
118
118
}
119
119
120
120
121
121
/**
122
122
* @return $this
123
123
*/
124
- public function find ()
124
+ public function findAll ()
125
125
{
126
126
$ this ->response = null ;
127
- $ this ->multipleResults = false ;
127
+ $ this ->multipleResults = true ;
128
128
129
+ $ limit = $ this ->limit != null ? "top " .(int )$ this ->limit : "" ;
129
130
$ fields = !empty ($ this ->fields ) ? $ this ->fields : '* ' ;
130
131
$ where = $ this ->where != "" ? "where {$ this ->where }" : "" ;
131
132
$ order = $ this ->order != "" ? "order by {$ this ->order }" : "" ;
132
133
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 }" ;
134
135
135
136
$ col = $ this ->connection ->selectCollection ($ this ->collection );
136
137
$ this ->response = $ col ->query ($ query , $ this ->params );
@@ -142,17 +143,16 @@ public function find()
142
143
/**
143
144
* @return $this
144
145
*/
145
- public function findAll ()
146
+ public function find ()
146
147
{
147
148
$ this ->response = null ;
148
- $ this ->multipleResults = true ;
149
+ $ this ->multipleResults = false ;
149
150
150
- $ limit = $ this ->limit != null ? "top " .(int )$ this ->limit : "" ;
151
151
$ fields = !empty ($ this ->fields ) ? $ this ->fields : '* ' ;
152
152
$ where = $ this ->where != "" ? "where {$ this ->where }" : "" ;
153
153
$ order = $ this ->order != "" ? "order by {$ this ->order }" : "" ;
154
154
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 }" ;
156
156
157
157
$ col = $ this ->connection ->selectCollection ($ this ->collection );
158
158
$ this ->response = $ col ->query ($ query , $ this ->params );
0 commit comments