Download the PHP package phpdevcommunity/relational-query without Composer
On this page you can find all versions of the php package phpdevcommunity/relational-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpdevcommunity/relational-query
More information about phpdevcommunity/relational-query
Files in phpdevcommunity/relational-query
Package relational-query
Short Description A lightweight PHP query builder with built-in relational query support. Easily build complex SQL queries and fetch results as arrays.
License MIT
Informations about the package relational-query
PHP SQL Query Builder
A lightweight PHP query builder for easy database interactions.
Installation
You can install this library via Composer. Make sure your project meets the minimum PHP version requirement of 7.4 or higher.
Usage
The SQL Query Builder library allows you to build SQL queries fluently using an object-oriented approach. Here are some examples of usage:
Creating a SELECT Query
Types of SQL Joins with QueryBuilder
The SQL Query Builder library supports various types of JOIN operations to combine rows from multiple tables based on a related column between them. Below are examples of different JOIN types you can use with QueryBuilder
:
1. INNER JOIN
An INNER JOIN returns records that have matching values in both tables.
2. LEFT JOIN
A LEFT JOIN returns all records from the left table (first table) and the matched records from the right table (second table). If there is no match, the result is NULL on the right side.
3. RIGHT JOIN
A RIGHT JOIN returns all records from the right table (second table) and the matched records from the left table (first table). If there is no match, the result is NULL on the left side.
Creating a SELECT Query with DISTINCT
You can use the distinct()
method to specify a SELECT DISTINCT
query with QueryBuilder.
Creating a SELECT Query with GROUP BY
You can use the groupBy()
method to specify a GROUP BY
clause with QueryBuilder.
Creating a SELECT Query with HAVING Clause
You can use the having()
method to specify a HAVING
clause with QueryBuilder.
Creating an INSERT Query
Creating an UPDATE Query
Creating an DELETE Query
Creating a SELECT Query with Custom Expression
List of Available Expressions (Expr
)
Here is a comprehensive list of available static methods in the Expr
class along with examples demonstrating their usage:
Expr::equal(string $key, string $value)
Expr::notEqual(string $key, string $value)
Expr::greaterThan(string $key, string $value)
Expr::greaterThanEqual(string $key, string $value)
Expr::lowerThan(string $key, string $value)
Expr::lowerThanEqual(string $key, string $value)
Expr::isNull(string $key)
Expr::isNotNull(string $key)
Expr::in(string $key, array $values)
Expr::notIn(string $key, array $values)
These examples demonstrate how to use each Expr
class method to generate SQL expressions for various comparison and conditional operations. Incorporate these methods into your SQL Query Builder usage to construct complex and precise SQL queries effectively.
Features
- Fluent generation of SELECT, INSERT, UPDATE, and DELETE queries.
- Secure SQL query building to prevent SQL injection vulnerabilities.
- Support for WHERE, ORDER BY, GROUP BY, HAVING, LIMIT, and JOIN clauses.
- Simplified methods for creating custom SQL expressions.
License
This library is open-source software licensed under the MIT license.
All versions of relational-query with dependencies
ext-pdo Version *