Bolt\Storage\Query\QueryResultset::get PHP Method

get() public method

Allows retrieval of a set or results, if a label has been used to store results then passing the label as a parameter returns just that set of results.
public get ( string $label = null ) : ArrayIterator
$label string
return ArrayIterator
    public function get($label = null)
    {
        if ($label && array_key_exists($label, $this->results)) {
            return $this->results[$label];
        } else {
            $results = [];
            foreach ($this->results as $v) {
                if (is_array($v)) {
                    $results = array_merge($results, $v);
                } else {
                    $results[] = $v;
                }
            }
            return $results;
        }
    }

Usage Example

Example #1
0
 public function testNoLabelFetch()
 {
     $array1 = ['test1', 'test2', 'test3'];
     $array2 = ['test4', 'test5', 'test6'];
     $set = new QueryResultset();
     $set->add($array1);
     $set->add($array2);
     $this->assertEquals(6, count($set->get()));
 }
QueryResultset