Ejemplo n.º 1
0
 public function testQueryLimit()
 {
     $query = $this->dm->createQuery('SELECT * FROM [nt:unstructured] WHERE ISCHILDNODE("/functional") ORDER BY username', \PHPCR\Query\QueryInterface::JCR_SQL2);
     $this->assertInstanceOf('PHPCR\\Query\\QueryInterface', $query);
     $query->setLimit(2);
     $result = $this->dm->getDocumentsByQuery($query, $this->type);
     $this->assertCount(2, $result);
     $ids = array();
     $vals = array();
     $nums = array();
     foreach ($result as $obj) {
         $this->assertInstanceOf('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\QuerySql2TestObj', $obj);
         $ids[] = $obj->id;
         $vals[] = $obj->username;
         $this->assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $obj->numbers);
         $nums[] = $obj->numbers->toArray();
     }
     $this->assertEquals(array('/functional/node5', '/functional/node1'), $ids);
     $this->assertEquals(array(null, 'dbu'), $vals);
     $this->assertEquals(array(array(3, 1, 2), array(3, 1, 2)), $nums);
 }
Ejemplo n.º 2
0
 /**
  * Create a new QueryBuilder instance that is prepopulated for this document name
  *
  * @return QueryBuilder $qb
  */
 public function createQuery()
 {
     return $this->_dm->createQuery()->from($this->_documentName);
 }
 /**
  * Create a new Query instance that is prepopulated for this document name
  *
  * @return Query $qb
  */
 public function createQuery()
 {
     return $this->dm->createQuery()->find($this->documentName);
 }