Új hozzászólás Aktív témák

  • lezso6

    HÁZIGAZDA

    válasz modder #18 üzenetére

    (#17) Sk8erPeter: Nagyképűség ON ;] :P :DDD

    Nem kell fetchelni:

    class PostgresResult implements Iterator
    {
    private $_connection;

    private $_result = NULL;

    private $_key = 0;

    private $_size;

    private $_cache = array();

    public function __construct($connection)
    {
    $this->_connection = $connection;
    }

    public function __destruct()
    {
    pg_free_result($this->_result);
    }

    public function current()
    {
    if($this->_result === null) {
    $this->_result = pg_get_result($this->_connection);
    $this->_size = pg_num_rows($this->_result);
    }
    if(!isset($this->_cache[$this->_key])) {
    $this->_cache[$this->_key] = pg_fetch_assoc($this->_result, $this->_key);
    }

    return $this->_cache[$this->_key];
    }

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

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

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

    public function valid()
    {
    return $this->_key < $this->_size;
    }
    }

Új hozzászólás Aktív témák

Hirdetés