public function BiblioEntrezClient::count in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/pubmed/EntrezClient.php \BiblioEntrezClient::count()
- 6 pubmed/EntrezClient.php \BiblioEntrezClient::count()
- 7.2 modules/pubmed/EntrezClient.php \BiblioEntrezClient::count()
Returns the number of results for the previously set search terms.
Return value
int
Throws
Exception
File
- modules/
pubmed/ EntrezClient.php, line 352 - Provides Entrez client to retrieve items from the NCBI databases.
Class
Code
public function count() {
if (is_null($this->count)) {
$params['tool'] = $this
->getTool();
$params['email'] = $this
->getEmail();
$params['db'] = $this
->getDatabase();
$params['term'] = $this
->getTerm();
$params['rettype'] = 'count';
if (isset($this->dateRange)) {
$params['mindate'] = $this
->getMinDate();
$params['maxdate'] = $this
->getMaxDate();
}
$this->query = self::BASE_URL . 'esearch.fcgi?' . http_build_query($params);
$result = @simplexml_load_file($this->query);
if (!$result) {
throw new Exception('Query ' . $this->query . ' failed.');
}
if (isset($result->Count)) {
$this->count = (int) $result->Count;
}
}
return $this->count;
}