Skip to content

Commit 4283cf6

Browse files
committed
Merge pull request top-think#265 from MouLingtao/master
修复MongoModel的getField方法不能获取值的BUG
2 parents 4c74395 + d52fbb0 commit 4283cf6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ThinkPHP/Library/Think/Model/MongoModel.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ public function getField($field,$sepa=null) {
306306
// 返回数据个数
307307
if(true !== $sepa) {// 当sepa指定为true的时候 返回所有数据
308308
$options['limit'] = is_numeric($sepa)?$sepa:1;
309-
} // 查找一条记录
310-
$result = $this->db->find($options);
309+
} // 查找符合的记录
310+
$result = $this->db->select($options);
311311
if(!empty($result)) {
312-
if(1==$options['limit']) return reset($result[0]);
312+
if(1==$options['limit']) return reset($result)[$field];
313313
foreach ($result as $val){
314314
$array[] = $val[$field];
315315
}

0 commit comments

Comments
 (0)