Download the PHP package phpgt/sqlbuilder without Composer

On this page you can find all versions of the php package phpgt/sqlbuilder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sqlbuilder

Object oriented representation of SQL queries.

This library does not generate any SQL, instead it provides an object oriented representation of SQL queries, allowing the structure of queries to be defined by the developer whilst gaining the benefits of inheritance.

When a PHP application reaches scale, it is often the database that is the performance bottleneck. When queries are generated on behalf of the developer, they are often difficult to optimise because control is lost. With SqlBuilder, the developer is always in control of the raw SQL.


Build status

Code quality

Code coverage

Current version

PHP.Gt/SqlBuilder documentation

Example usage: a class that represents a SELECT query

Imagine a typical database application with a student table used to store details of each student. A basic select might look something like this:

The above query will return a list of all students. The problem here is that when you come to need to select from the student table again, this time with some constraints such as an age range or ordered by surname, the whole query will need to be repeated and only a small portion of the original query will need to be changed.

Instead, the following class can be used to represent the above query:

The __toString method of the above class will produce identical SQL to the original query.

Now, to write another query that returns students of a certain age:

Example usage: A fluent class that builds a SELECT query (coming in v2 release)

As you can see in the example above, SqlQuery functions always return an array of expressions. The SqlBuilder classes have the same methods (select, from, where, etc.) but take the expressions as parameters, acting as a fluent interface.

To create the same query as in the example above with fluent syntax:

This is particularly useful for when there is a base query, say StudentSelect, and your code only requires a single additional condition. Rather than having to create a separate class for this single usage, it can be called inline:

Conditionals

Expressions within where and having clauses can be connected with logical operators, which are often combined. To avoid logical errors, Condition objects are used to specify the precedence of logic.

For example, to select students with a specific age and gender:

Subqueries

SqlQuery objects have a __toString() function, and SqlBuilder results create SqlQuery instances. Because of this, they can be used in place of any other expression within a Query or Builder.

Limitations of plain SQL

The only tools provided by plain SQL that can be used to write DRY code are views and stored procedures, both of which have their own set of limitations when writing clean and maintainable code.

The solution provided by this library is to break down an SQL query into its different sections, represented by a PHP class which can be extended by other classes, while still retaining the plain SQL that is being represented.

SQL compatibility

This library does not provide any SQL processing capabilities by design. Any driver-specific SQL used will not be compatible with other drivers. This allows the developer to fully utilise their SQL driver of choice, rather than generating generic SQL.


All versions of sqlbuilder with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpgt/sqlbuilder contains the following files

Loading the files please wait ....