Skip to content

Commit c42d8c7

Browse files
committed
Add number of records per request as second (optional) argument to Client::records(), update README
1 parent 2b9351c commit c42d8c7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
[![Build Status](https://img.shields.io/travis/scriptotek/php-sru-client.svg)](https://travis-ci.org/scriptotek/php-sru-client)
32
[![Coverage Status](https://img.shields.io/coveralls/scriptotek/php-sru-client.svg)](https://coveralls.io/r/scriptotek/php-sru-client?branch=master)
43

@@ -39,7 +38,12 @@ $client = new SruClient($url, array(
3938
'version' => '1.1',
4039
'user-agent' => 'OpenKat/0.1'
4140
));
41+
```
4242

43+
To iterate over all the results from a `searchRetrieve` query, use the [Records](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Records.html) class returned from `Client::records()`. It abstracts away the process of actually making the requests. The first argument is
44+
the CQL query, and the second optional argument is the number of records to fetch for each request (defaults to 10).
45+
46+
```php
4347
$records = $client->records('dc.title="Hello world"');
4448
foreach ($records as $record) {
4549
echo "Got record " . $record->position . " of " . $records->numberOfRecords() . "\n";

src/Client.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ public function search($cql, $start = 1, $count = 10) {
144144
* Perform a searchRetrieve request and return an iterator over the records
145145
*
146146
* @param string $cql
147+
* @param int $count Number of records to request per request
147148
* @return Records
148149
*/
149-
public function records($cql)
150+
public function records($cql, $count = 10)
150151
{
151-
return new Records($cql, $this);
152+
return new Records($cql, $this, $count);
152153
}
153154

154155
/**

0 commit comments

Comments
 (0)