Skip to content

v1.3.0

Latest

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:01

Added

  • Subquery support for where() / andWhere() / orWhere(): pass a nested QueryBuilder
    instance as a condition value and it compiles to a parenthesized (SELECT ...) subquery, with
    the subquery's own bindings merged into the parent's bindings array in the exact left-to-right
    order they appear in the rendered SQL.
    • Primary supported pattern: WHERE ... IN (subquery), e.g.
      where('id', 'IN', QueryBuilder::table('orders')->select(['user_id'])->where('total', '>', 100))
      compiles to `id` IN (SELECT `user_id` FROM `orders` WHERE `total` > ?) with the subquery's
      bindings correctly appended after any preceding outer bindings.
    • A subquery also works as a plain scalar comparison value (where('id', '=', $subquery))
      via the same detection path.
    • Extends the library's core "never interpolate a value into raw SQL" guarantee recursively to
      nested queries, with new regression tests (including a malicious-value-inside-a-subquery
      case and real SQLite execution of a subquery-bearing query) in tests/run.php.

See CHANGELOG.md and the new "Subqueries" section in README.md for details and examples.