Hello,
I'm new to BaseX but am finding it very useful for somethings I'm working on. Today I've been working with the BaseX client for PHP and QueryExample.php fails for me saying the functions more() and next() are not defined.
I'm not a PHP expert so I'm not sure if there is another way of achieving the same thing - but I did find an email chain on this list from April which suggested that the functions were missing and needed to be written by someone.
I have taken the Ruby client as a guide and created the two functions in PHP but I'm just not sure that I've done it in the neatest way.
1) Is there a better way in PHP to get each result of a query so that more() and next() are not needed?
2) If not might my version of these functions be useful? If so, what is the process for submitting code?
Thank you for your help.
Regards, James
Add two class variables $pos and $cache.
public function more() { if ($this->cache == NULL) { $this->pos = 0; $this->session->send(chr(4).$this->id.chr(0)); while (!$this->session->ok()) { $temp = $this->session->readString(); $this->cache[] = $temp; } } return $this->pos < count($this->cache); }
public function next() { if($this->more()) { return $this->cache[$this->pos++]; } }