<?php

/**
 * Description of Core
 *
 * @author Arkadiusz Rychlik <a.rychlik at eppe.com.pl>
 */
class Rtn_Mssql_Result_Core implements Iterator, Countable {

	private $position;
	private $result;
	private $num_rows;

	public function __construct($mssql_result) {
		$this->result = $mssql_result;
		$this->num_rows = mssql_num_rows($this->result);
	}

	public function current() {
		mssql_data_seek($this->result, $this->position);
		return mssql_fetch_object($this->result);
	}

	public function key() {
		return $this->position;
	}

	public function next() {
		$this->position++;
	}

	public function rewind() {
		$this->position = 0;
	}

	public function valid() {
		return ($this->position < $this->num_rows);
	}

	public function count() {
		return $this->num_rows;
	}

}
