Skip to content

Commit

Permalink
增加方法: getClient 来获取官方的Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jea committed Dec 5, 2018
1 parent 2a5017e commit f3cf589
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public function setHost($host = 'localhost', $port = 9200)

return $this;
}

/**
* @throws \Exception
*/
public function getClient(){
if(empty($this->hosts)){
throw new \Exception('using getClient , You must set host before');
}
if($this->client == null) {
$this->client = self::create()->setHosts($this->hosts)->build();
}
return $this->client;
}

/**
* 查询特定的字段, 从数据库中
Expand Down

0 comments on commit f3cf589

Please sign in to comment.