I'm trying to dynamicly make my rethinkdb queries but whey I use the following code:
<?php
require_once "rdb/rdb.php";
ini_set('memory_limit', '-1');
$conditions = [];
$conn = r\connect('10.7.96.5:28015');
if (isset($_GET["alive"])) {
$conditions[] = r\row("alive")->eq("true" === $_GET["alive"]);
}
if (isset($_GET["times_alive"])) {
$conditions[] = r\row("times_alive")->ge((int) $_GET["times_alive"]);
}
for ($i = 0; $i < count($conditions); $i++) {
if (0 == $i) {
$condition = $conditions[$i];
} else {
$condition .= ->rAnd($conditions[$i]);
}
}
$result = r\db('proxyscrape')->table("proxies")->filter(
$condition
)->run($conn);
foreach ($result as $doc) {
print_r($doc);
}
I get the following error:
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /var/www/html/test3.php on line 20
The expected result I'm looking for in $condition is
r\row("alive")->eq("true" === $_GET["alive"])->rAnd(r\row("times_alive")->ge((int) $_GET["times_alive"])
Got it working by changing
$condition .= ->rAnd($conditions[$i]);
To
$condition = $condition->rAnd($conditions[$i]);