Aura.SqlQuery
Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.
A PHP library that builds SQL queries through method calls instead of hand-written SQL strings, supporting MySQL, PostgreSQL, SQLite, and SQL Server with built-in protection against common security vulnerabilities.
Aura.SqlQuery is a PHP library that helps developers build database queries without writing raw SQL strings by hand. Instead of typing out something like "SELECT name FROM users WHERE age > 30," you use a series of simple method calls, and the library constructs the correct SQL statement for you. It supports four popular database systems: MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.
At a high level, you start by telling a central "factory" which type of database you are using. The factory then hands you builder objects for standard operations: selecting, inserting, updating, and deleting data. You chain commands together to specify columns, tables, joins, and conditions. Importantly, these builder objects do not actually connect to or talk to your database; they only generate the final SQL string and safely separate user inputs (like search terms) to protect against common security vulnerabilities. You then hand that finished string to your own database connection to run it.
This tool is ideal for PHP developers who want to write database-portable applications or simply prefer a cleaner, more structured way to manage complex queries. For example, a developer building an inventory dashboard can use it to construct a search filter step-by-step. If they later switch the underlying database from MySQL to PostgreSQL, they can largely reuse the same code without rewriting their queries. It also supports advanced features like bulk inserting multiple rows at once.
A notable design choice is that it deliberately stays independent of any specific database connection tool. By focusing solely on generating SQL, it leaves the actual data retrieval to whatever system the developer already has in place. It also offers a "common" mode that restricts queries to standard operations, making it easier to write software that runs smoothly across different database engines.
Where it fits
- Build an inventory dashboard with step-by-step search filters without writing raw SQL.
- Write a PHP app that can switch between MySQL and PostgreSQL without rewriting queries.
- Construct safe bulk insert statements for multiple rows at once using method calls.