Download the PHP package hindbiswas/quebee without Composer
On this page you can find all versions of the php package hindbiswas/quebee. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hindbiswas/quebee
More information about hindbiswas/quebee
Files in hindbiswas/quebee
Package quebee
Short Description Qb - a lightweight Query Builder for SQL
License MIT
Informations about the package quebee
QueBee: A PHP SQL Query Builder
Introduction
The QᴜᴇᴇBᴇᴇ (QB) or Query Builder package is a lightweight package for Building MySQL Queries. It is a PHP package that simplifies the construction of SQL queries. It provides an object-oriented approach to building SQL queries, making it easier to create, modify, and execute SQL statements in your PHP applications.
Installation
1. Composer
QueBee can be installed via Composer, a PHP dependency manager. If you haven't installed Composer yet, visit composer's website for instructions.
Run the following command to install QueBee:
2. Autoloading
Ensure that Composer's autoloader is included in your project's PHP files.
Use your path in place of path/to/
:
Features
QueBee provides following features to work with MySQL:
- Queries:
Query
class forSELECT
,INSERT
,UPDATE
, andDELETE
queries. - Table:
Table
class forCREATE TABLE
along withCol
class for columns. - Columns:
Col
class has a bunch of datatypes likeINT
,VARCHAR
,DATETIME
and many more for creating columns as per your requirements. - Statements:
Stmt
class forUNION
,UNION ALL
,CUBE
,SET
, andGROUPING SETS
statements.
It also includes foreign key constraints, unique, primary key and indexing as well as grouping. See the /tests/
directory for all possible ways of using the QueBee
;
Usage
Below are examples of how to use each query builder.
1. SELECT Query
To create a SELECT
query, use the Query::select()
method:
Or,
condition aliases for conditional statements
SQL | Literal | Symbolic |
---|---|---|
> |
gt |
> |
>= |
gte |
>= |
< |
lt |
< |
<= |
lte |
<= |
= |
eq |
== or = |
!= |
ne |
!= or <> |
<=> |
ns |
<=> |
LIKE |
like |
?? |
You can use either Literal or Symbolic.
2. INSERT Queries
To create an INSERT
query, use the Query::insert()
method (To insert multiple rows at once, use the Query::insertMultiple()
method):
3. UPDATE Queries
To create an UPDATE
query, use the Query::update()
method:
4. DELETE Queries
To create a DELETE
query, use the Query::delete()
method:
5. CREATE TABLE Queries
To create a CREATE TABLE
query, use the Table::create()
method:
Without Any Foreign Keys
With Foreign Keys
Available Data Types as of v1.2.0
- String
- TEXT =>
Col::text()
- VARCHAR =>
Col::varchar(225)
- TEXT =>
- Numeric
- BIT =>
Col::bit()
- INT =>
Col::integer()
- BIGINT =>
Col::bigInt()
- MEDIUMINT =>
Col::mediumInt()
- SMALLINT =>
Col::smallInt()
- TINYINT =>
Col::tinyInt()
- DECIMAL =>
Col::decimal(11, 6)
- FLOAT =>
Col::float(6, 2)
- DOUBLE =>
Col::double(11, 6)
- REAL =>
Col::real(11, 6)
- BIT =>
- Time
- DATE =>
Col::date()
- DATETIME =>
Col::dateTime()
- DATE =>
Best Practices
Here are some best practices when using QueBee:
-
Sanitize User Inputs: Always sanitize user inputs before using them in queries.
-
Error Handling: Handle exceptions appropriately, especially when building queries. QueBee can throw exceptions for invalid input or method calls.
-
Database Abstraction: Consider using a database abstraction layer alongside QueBee for more extensive database interactions.
- Code Organization: Organize your code logically, separating query building from execution and result handling.
Conclusion
QueBee simplifies SQL query construction in PHP, making it easier to build clean, secure, and efficient database interactions. With its fluent API, it provides a user-friendly way to create SQL queries for various database systems.
For more detailed usage and customization options, refer to the QueBee GitHub repository.
That's it! You're ready to start using QueBee for building SQL queries in your PHP applications.