Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijastuden committed Dec 20, 2015
1 parent dc0a97c commit 4ba62d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ Recently we added `ScrapInterface`. This interface should be implemented by mode

## Finder

To set conditions, use `where` method:

```php
$pool->find(Writer::class)
->where('`birthday` > ?', '1800-01-01')
->ids();
```

This method can be called multiple times, and all conditions will be joined in one block with `AND` operator:

```php
$pool->find(Writer::class)
->where('`birthday` > ?', '1800-01-01')
->where('`birthday` < ?', '1825-01-01')
->ids();
```

Finder can join a table, either by table name:

```php
Expand Down
4 changes: 2 additions & 2 deletions test/src/FindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public function testFindByMultipleConditions()

$this->assertCount(2, $should_be_fyodor_and_leo);

$finder_2 = $this->pool->find(Writer::class)->where('`birthday` > ?', '1800-01-01')->where('birthday < ?', '1825-01-01');
$this->assertEquals("(`birthday` > '1800-01-01') AND (birthday < '1825-01-01')", $finder_2->getWhere());
$finder_2 = $this->pool->find(Writer::class)->where('`birthday` > ?', '1800-01-01')->where('`birthday` < ?', '1825-01-01');
$this->assertEquals("(`birthday` > '1800-01-01') AND (`birthday` < '1825-01-01')", $finder_2->getWhere());

/** @var Writer[] $should_be_fyodor */
$should_be_fyodor = $finder_2->all();
Expand Down

0 comments on commit 4ba62d9

Please sign in to comment.