Xpressengine\Draft\DraftRepository::fetch PHP Méthode

fetch() public méthode

임시저장 데이터 목록을 반환
public fetch ( array $options ) : array
$options array 검색할 조건
Résultat array
    public function fetch(array $options)
    {
        $query = $this->conn->table($this->table);
        foreach ($options as $column => $value) {
            $query->where($column, $value);
        }
        $rows = $query->get();
        $items = [];
        foreach ($rows as $row) {
            $items[] = $this->createItem((array) $row);
        }
        return $items;
    }

Usage Example

 public function testFetch()
 {
     list($conn, $keygen, $query) = $this->getMocks();
     $instance = new DraftRepository($conn, $keygen);
     $conn->shouldReceive('table')->andReturn($query);
     $query->shouldReceive('where')->once()->with('userId', 'userId')->andReturnSelf();
     $query->shouldReceive('where')->once()->with('key', 'someKey')->andReturnSelf();
     $query->shouldReceive('get')->once()->andReturn([['id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'key' => 'someKey', 'val' => 'qux', 'etc' => 'a:1:{s:3:"foo";s:3:"bar";}'], ['id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxy', 'key' => 'someKey', 'val' => 'qux1', 'etc' => 'a:1:{s:3:"foo";s:3:"baz";}']]);
     $drafts = $instance->fetch(['userId' => 'userId', 'key' => 'someKey']);
     $this->assertEquals(2, count($drafts));
 }
All Usage Examples Of Xpressengine\Draft\DraftRepository::fetch