/**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Checks if current position is valid
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  * Returns true on success or false on failure.
  */
 public function valid()
 {
     if ($this->stored !== null) {
         return $this->cursor >= 0 && $this->cursor < count($this->stored);
     }
     return $this->cursor >= 0 && $this->connection->getConnection()->more_results();
 }
 public function testIterator()
 {
     $expect = array(0 => array('id' => '10', 'gid' => '9003'), 1 => array('id' => '11', 'gid' => '201'));
     $this->refill();
     $res = self::$conn->query('SELECT * FROM rt');
     $array = array();
     foreach ($res as $key => $value) {
         $array[$key] = $value;
     }
     $this->assertSame($expect[0], $array[0]);
     $this->assertSame($expect[1], $array[1]);
     $res = self::$conn->query('SELECT * FROM rt WHERE id = 404');
     $array = array();
     foreach ($res as $key => $value) {
         $array[$key] = $value;
     }
     $this->assertEmpty($array);
 }
 /**
  * Get the PHP MySQLi object
  *
  * @return \mysqli
  * @throws ConnectionException
  */
 public function getMysqliConnection()
 {
     return $this->connection->getConnection();
 }
 /**
  * @param array $config
  * @return void
  */
 public function initialize(array $config)
 {
     $this->conn = new Connection();
     $this->conn->setParams(['host' => $this->config('connection')['host'], 'port' => $this->config('connection')['port']]);
 }