The Query Builder Form interface allows administrators to build dynamic database queries either using step-by-step visual UI blocks (Normal Query Builder) or by writing free-form SQL text statements (Custom Query Mode).
Query Builder supports two distinct operational modes:
Interactive block-based interface where administrators select Base Tables, output columns, joins, filter conditions, group by rules, and sort orders without writing SQL code.
Free-form SQL text editor activated by clicking "Custom Query". Best for complex SQL queries (CASE WHEN, UNION, subqueries) and session parameter tags ({company_id}, {current_user}).
Main metadata inputs located at the top of the Query Builder Form:
| Field Name | Input Type | Description & Requirement |
|---|---|---|
| Query Builder Name * | Text Input | Human-readable query title (e.g. User Details). Mandatory. |
| Query Builder Slug * | Text Input | Unique system slug used in code calls (e.g. user-details). Mandatory. |
| Base Table * | Dropdown | Primary database table. Selecting table loads columns automatically. Mandatory in Normal Mode. |
| Query Builder Description | Textarea | Description of query purpose and usage notes. Optional. |
| Query Type * | Dropdown | Operation type: SELECT (1), INSERT (2), or UPDATE (3). Mandatory. |
| Store Variable * | Text Input | PHP variable storing query result set (e.g. userDetails). Mandatory in Normal Mode. |
When a Base Table is selected, its columns display automatically with checkboxes:
SELECT clause.oj1.nm_first_name).AS nm_partner) for joined reference fields.Click "+ Join" to add relational table joins:
nm_app_schema_reference_key.LEFT, RIGHT, or INNER join.oj2, oj3) automatically.oj1.nm_company_id = oj2.nm_company_id).Click "+ Condition" to build filtering rules:
=, !=, >, <, >=, <=, LIKE, IN, NOT IN, IS NULL, IS NOT NULL.{current_user} or {company_id} for dynamic context evaluation. Click "+ Order" to specify sorting columns and direction (ASC or DESC). Supports multiple ordering columns.
Numeric inputs defining maximum row return count (LIMIT) and starting row index (OFFSET).
Click "Custom Query" (btnCustomQuery) to switch to Custom Query Mode:
CASE WHEN, UNION, subqueries, and custom joins.{company_id} or {current_user}."is_custom": true, "raw_sql", and "custom_sql" in nm_query_json.Click "GENERATE QUERY" before saving:
nm_query_json) and SQL string preview.| Dimension | Normal Query Builder | Custom Query Mode |
|---|---|---|
| Query Construction | UI block builder (+ Join, + Condition) | Direct free-form SQL text editor |
| Base Table | Mandatory selection from dropdown | User writes SQL statement directly |
| Select Columns | Checkbox selection with auto-alias | Custom SQL controls SELECT statement |
| Join Restrictions | Restricted to nm_app_schema_reference_key | Custom SQL supports any valid JOIN syntax |
| Compilation | Compiles UI blocks into JSON | Stores raw SQL with "is_custom": true |