Hi James,
finally some feedback: thanks for your client code. I have slightly updated the snippet and submitted it to our repository [1]. Next, I‘ve also mentioned you in our Wiki [2], and I have revised our Server Protocol documentation and added some exemplary client/server byte exchange [3].
Any additional feedback to this and the other clients is welcome, Christian
[1] https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.ph... [2] http://docs.basex.org/wiki/Clients [3] http://docs.basex.org/wiki/Server_Protocol ___________________________
On Wed, May 22, 2013 at 11:35 PM, James Ball basex@jamesball.co.uk wrote:
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.
Is there a better way in PHP to get each result of a query so that more() and next() are not needed?
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++]; } } _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk