fetch() public method

Runs the query and fetches the results.
public fetch ( ) : QueryResultset
return QueryResultset
示例#1
0
 public function testSingleItemMode()
 {
     $app = $this->getApp();
     $qb = new ContentQueryParser($app['storage'], $app['query.select']);
     $qb->setQuery('pages/5');
     $qb->setParameter('printquery', true);
     $qb->parse();
     $this->assertEquals(['pages'], $qb->getContentTypes());
     $this->assertEquals('namedselect', $qb->getOperation());
     $this->assertEquals('5', $qb->getIdentifier());
     $this->expectOutputString('SELECT pages.* FROM bolt_pages pages WHERE pages.id = :id_1');
     $res = $qb->fetch();
     $this->assertInstanceOf('Bolt\\Storage\\Entity\\Content', $res);
 }
示例#2
0
 public function testNativeSearchHandlerFallback()
 {
     $app = $this->getApp();
     $qb = new ContentQueryParser($app['storage'], $app['query.select']);
     $qb->addService('search', $app['query.search']);
     $qb->addService('search_weighter', $app['query.search_weighter']);
     $qb->setQuery('pages/nativesearch/4');
     $qb->setParameters(['filter' => 'lorem ipsum']);
     $res = $qb->fetch();
     $this->assertEquals(4, $res->count());
 }
示例#3
0
 public function testLatestHandler()
 {
     $this->resetDb();
     $app = $this->getApp();
     $this->addSomeContent($app);
     $qb = new ContentQueryParser($app['storage'], $app['query.select']);
     $qb->setQuery('pages/latest/4');
     $res = $qb->fetch();
     $this->assertEquals(4, count($res));
     $count = 5;
     foreach ($res as $item) {
         $this->assertEquals($count, $item['id']);
         $count--;
     }
 }