diff --git a/php/src/db/_private/_base.php b/php/src/db/_private/_base.php index 4717cfe..6ea42e7 100644 --- a/php/src/db/_private/_base.php +++ b/php/src/db/_private/_base.php @@ -103,6 +103,29 @@ abstract class _base { $condkey++; } break; + case "any": + case "all": + case "not any": + case "not all": + # ["list", $values] + if ($op === "any" || $op === "all") { + $condprefix = $op; + $op = "="; + } elseif ($op === "not any" || $op === "not all") { + $condprefix = substr($op, strlen("not ")); + $op = "<>"; + } + $condprefix .= "(array["; + $condsep = ", "; + $condsuffix = "])"; + $condvalues = null; + if (array_key_exists("values", $cond)) { + $condvalues = cl::with($cond["values"]); + } elseif (array_key_exists($condkey, $condkeys)) { + $condvalues = cl::with($cond[$condkeys[$condkey]]); + $condkey++; + } + break; case "in": # ["in", $values] $condprefix = "("; diff --git a/php/tests/db/_private/_baseTest.php b/php/tests/db/_private/_baseTest.php new file mode 100644 index 0000000..cd2d758 --- /dev/null +++ b/php/tests/db/_private/_baseTest.php @@ -0,0 +1,22 @@ + ["any", $values], + ], $sql, $bindings); + self::assertSame([ + "value = any(array[:value, :value2])", + ], $sql); + self::assertSame([ + "value" => 1, + "value2" => "string", + ], $bindings); + } +}