Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Implemented skip in findBy method in Repository class #157

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Doctrine/ODM/OrientDB/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public function findBy(array $criteria, array $orderBy = array(), $limit = null,
$query->orderBy("$key $order");
}

if ($offset) {
$query->skip($offset);
}

if ($limit) {
$query->limit($limit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CurlClientResponse
const STATUS_NO_CONTENT = 204;
const STATUS_RESET_CONTENT = 205;
const STATUS_PARTIAL_CONTENT = 206;
const STATUS_CONTINUE = 100;

/**
* Constructs a new object from an existing HTTP response.
Expand Down Expand Up @@ -118,7 +119,8 @@ public function getValidStatusCodes()
self::STATUS_NO_CONTENT,
self::STATUS_RESET_CONTENT,
self::STATUS_PARTIAL_CONTENT,
self::STATUS_CREATED
self::STATUS_CREATED,
self::STATUS_CONTINUE
);
}

Expand Down
5 changes: 5 additions & 0 deletions test/Doctrine/ODM/OrientDB/Integration/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public function testRetrievingByCriteria()

$posts = $repository->findBy(array(), array('@rid' => 'ASC'), 1);
$this->assertCount(1, $posts);

$post0Rid = $posts[0]->getRid();
$posts = $repository->findBy(array(), array('@rid' => 'ASC'), 4, 1);
$this->assertCount(3, $posts);
$this->assertTrue($posts[0]->getRid() != $post0Rid);
}

public function testRetrievingARecordByCriteria()
Expand Down