0

I'm using ratchet php to check every second for changes made in a rethink db table. But the changes() doesn't return anything even though i edit the document. What am I doing wrong here?

I did refer to this post: rethinkdb PHP-RQL changes

This is how I query for changes in RethinkDB

function fetchProduct() {
    $products = r\table("tableOne")->changes()->run($conn);

            foreach ($products as $product) {
               $p[] = $product;
            }

            return $p;

}

This is how I check for changes via Rachet every second:

$count = 0;

loopy($server, $count);

function loopy($server, $count) {    

   $server->loop->addPeriodicTimer(1, 


     function ($timer) use ( &$server, &$count) {



         $count++;
            echo $count."\n";
            //test starts

            $product = fetchProduct();
            echo "<pre>";
            var_dump($product);
            //test ends

   });

}

But no data returned even when the document is edited. Also it stops the execution of the loop in Ratchet. If I removed the changes() then it will return all the document in the table every second as the Ratchet loop runs.But I want data returned only when changes are made. HOw do I achieve that?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
112233
  • 2,406
  • 3
  • 38
  • 88

1 Answers1

0

I just changed the iteration to this and it worked:

 foreach ($products as $product) {
            print_r($product);
        }
112233
  • 2,406
  • 3
  • 38
  • 88