PHP Classes
elePHPant
Icontem

Query Builder: Build SQL queries using a fluent interface

Recommend this page to a friend!
  Info   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-01-05 (9 months ago) RSS 2.0 feedStarStarStarStar 78%Total: 431 This week: 4All time: 5,987 This week: 267Up
Version License PHP version Categories
plug-query-builder 1.0.0MIT/X Consortium ...7.0Databases, PHP 7
Description Author

This class can build SQL queries using a fluent interface.

It can compose SQL SELECT, UPDATE, INSERT and DELETE queries using functions that define query parameters.

The parameters define the SQL query type, tables, conditions, field names and values.

Picture of Samuel Adeshina
  Performance   Level  
Name: Samuel Adeshina <contact>
Classes: 19 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Details

Plug-Query-Builder

An Intelligent Query Builder for the SQL Language. It generates a complete sql string by calling methods on a parent QueryBuilder() object

This SQL Query Builder works through method chaining. You can call subsequent methods on another recursively.

For example:

$query = new QueryBuilder()
		->select("first_name", "last_name")
		->from("EmployeeInfo")
		->where("employee_id < 563")
		->build();

__You finally build the sql query by calling the build() method on your QueryBuilder() object__

The build() method is the only method that returns a string data, every other method returns a new instance of a QueryBuilder() object

Supported SQL Methods

  • select(string ...$string) //zero or more string parameters
  • from(string $string)
  • where(string $string)
  • values(string ...$string)
  • into(string $string, QueryBuilder $query_builder_object = null) //optional second parameter
  • insert()
  • update(string $string)
  • set(string $string)
  • delete(string $string)

<i>You should know that:</i>

> This class is not an SQL string validator. It does not validate your sql queries. It only appends a string to another based on the method you've called. So if you append a where() method directly to a select() method, it still generates an sql string.

  Files folder image Files  
File Role Description
Files folder imagetests (1 file)
Files folder imagevendor (2 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file QueryBuilderTest.php Test Unit test script

  Files folder image Files  /  vendor  
File Role Description
  Plain text file BuildableInterface.php Class Class source
  Plain text file QueryBuilder.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:431
This week:4
All time:5,987
This week:267Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:-
Tests:91%StarStarStarStarStar
Videos:-
Overall:78%StarStarStarStar
Rank:43