Example #1
0
 /**
  * Internal method to seek to a specific row in a result resource
  *
  * @param Integer $offset The offset to seek to
  * @return NULL
  */
 public function seek($offset)
 {
     \r8\ary\seek($this->results, $offset);
 }
Example #2
0
 public function testSeek()
 {
     // Test setting the pointer to the end of the array
     $ary = array();
     $this->assertSame(NULL, \r8\ary\seek($ary, 0));
     $ary = range(100, 119);
     // Test setting the pointer to the end of the array
     $this->assertSame(119, \r8\ary\seek($ary, -1));
     $this->assertEquals(119, current($ary));
     // Test setting it to the beginning
     $this->assertSame(100, \r8\ary\seek($ary, 0));
     $this->assertEquals(100, current($ary));
     // Test seeking to the current location of the pointer
     next($ary);
     next($ary);
     next($ary);
     $this->assertSame(103, \r8\ary\seek($ary, 3));
     $this->assertEquals(103, current($ary));
     // Test seeking to a point closest to the end of the array
     $this->assertSame(117, \r8\ary\seek($ary, 17));
     $this->assertEquals(117, current($ary));
     // Test seeking to a point closest to the beginning of the array
     $this->assertSame(105, \r8\ary\seek($ary, 5));
     $this->assertEquals(105, current($ary));
     // Test seeking forward when the closest point is the current pointer
     $this->assertSame(107, \r8\ary\seek($ary, 7));
     $this->assertEquals(107, current($ary));
     // Test seeking backward when the closest point is the current pointer
     $this->assertSame(106, \r8\ary\seek($ary, 6));
     $this->assertEquals(106, current($ary));
 }