Download the PHP package hardeep-vicky/php-query-builder without Composer
On this page you can find all versions of the php package hardeep-vicky/php-query-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hardeep-vicky/php-query-builder
More information about hardeep-vicky/php-query-builder
Files in hardeep-vicky/php-query-builder
Package php-query-builder
Short Description Query builder Tool for Php
License MIT
Informations about the package php-query-builder
PHP MySQL Query Builder
This library required when you need to create MySQL Query using classes and arrays. This Library only for creating Select Query For MySQL Databse.
i have used SqlFormatter Library built by Jeremy Dorn [email protected] to format query in browser.
Feel Free to comment and if any one want to countribute then please contact me Hardeep Singh Contact me at [email protected]
Installation
Install Library using composer
Basic Usage/Examples
- First include composer's autoload file.
- QuerySelect class is main class for generating query which accpet a argument of class Table
- Table class accept three arguments
- First Table name (required)
- Second Alias (optional)
- primary field name (optional) (defaull id)
Output
SELECT
C.*
FROM
countries
AS C
WHERE
(C.name like '%india%')
Use with Complex Conditions
Output
Example with Join
Output
In above example we use Join class , Join class construct function is below
And we call
this statement make select name
field of states table. This function field()
has three option
Above options also avialable in QuerySelect class
you can set also no field as below
this statement make no field selction in query
Multiple Join
Output
You can get query without alias as below
Output
Join With Condition
We have two options here
Output
we can concat raw where string as below
Output
Another Examples are below
In above example we use custom field $querySelect->addCustomField("COUNT(S.id) AS state_count");
and conditions in having clause $querySelect->setHaving(Condition::init("AND")->add("state_count", 5, ">"));
Output
Output
🚀 About Me
I'm a PHP Developer creating web applications and php libraries since 2014. Contact me at [email protected]