0

I'm needing to create more than 1 filter to run a query to cut down the number of results found.

I am trying to do these 3 queries at once using RethinkDB for php found here

The code I am running is:

    $query = \r\table('payments')->filter(
        \r\row('forwarded')->eq('1'),
        \r\row('bad_callbacks_sent')->lt("1"),
        \r\row('confirmations')->le('7')
    )->run($this->conn);

I've just also tried doing the following and it doesn't work (it's just showing all where the first argument - where forwarded = 1. It's only doing the first filter:

     $query = \r\table('payments')
    ->filter(\r\row('forwarded')->eq('1'))
    ->filter(\r\row('bad_callbacks_sent')->lt("6"))
    ->filter(\r\row('confirmations')->le("7"))
    ->run($this->conn);

But it doesn't seem to be doing what I ask. I need to make it get:

  1. Where forwarded == 1
  2. Where bad_callbacks_sent < 1
  3. Where confirmations <= 7

I found this the following code from here, which shows that you can chain them in js but I'm wondering about PHP:

r.db('items').table('tokens')
.filter(r.row('valid_to').gt(r.now()))
.filter(r.row["processed"] == False)

Any ideas?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AGradePHP
  • 63
  • 5

1 Answers1

0

Okay so it turns out, the issue was not with my new code:

    $query = \r\table('payments')
    ->filter(\r\row('forwarded')->eq('1'))
    ->filter(\r\row('bad_callbacks_sent')->lt(6))
    ->filter(\r\row('confirmations')->le(7))
    ->run($this->conn);

But with the variable type. In my database, it was stored as an int but I was trying to read it via (le("7")) a string.

The above code works fine :) It allows you to filter more than 1 query in retihnkdb for php.

Make sure you check your variable types in your database! RethinkDB is very sensitive to what types they're.

Hope I save you some time.

AGradePHP
  • 63
  • 5