Download the PHP package solophp/query-builder without Composer

On this page you can find all versions of the php package solophp/query-builder. 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 query-builder

Solo PHP Query Builder

A lightweight and flexible SQL query builder for PHP 8.2+ with support for multiple SQL dialects.

Version License

Features

Installation

Quick Start

Caching (PSR-16)

This library supports caching SELECT query results via any PSR-16 cache implementation:

Manual Initialization

If you need more control over the initialization process, you can create all components manually:

Building without Executing

You can also build queries without executing them:

Multi-DBMS Support

The library implements SQL grammar abstraction, allowing you to work with different database systems using the same API.

Setting Default DBMS

SELECT Queries

Basic Selection Operations

Raw SQL Expressions

You can use raw SQL expressions by enclosing them in curly braces {...}:

Conditional Queries with when()

The when() method allows you to add clauses to your query conditionally:

JOIN Operations

Grouping and Aggregation

INSERT Queries

UPDATE Queries

DELETE Queries

Checking for Records

Transaction Support

API Reference

Query Methods

Method Description
from(string $table) Sets the table to select from
select(string ...$columns) Sets the columns to select
distinct(bool $value = true) Enables or disables DISTINCT selection
insert(string $table) Starts an insert query
update(string $table) Starts an update query
delete(string $table) Starts a delete query
setDatabaseType(string $type) Sets the database type (mysql, postgresql, sqlite)

Where Conditions

Method Description
where(string\|\Closure $expr, mixed ...$bindings) Adds a WHERE condition
orWhere(string\|\Closure $expr, mixed ...$bindings) Adds an OR WHERE condition
andWhere(string\|\Closure $expr, mixed ...$bindings) Adds an AND WHERE condition
whereIn(string $column, array $values) Adds a WHERE IN condition
orWhereIn(string $column, array $values) Adds an OR WHERE IN condition
andWhereIn(string $column, array $values) Adds an AND WHERE IN condition
when(bool $condition, callable $callback, ?callable $default = null) Conditionally adds clauses

Having Conditions

Method Description
having(string\|\Closure $expr, mixed ...$bindings) Adds a HAVING condition
orHaving(string\|\Closure $expr, mixed ...$bindings) Adds an OR HAVING condition
andHaving(string\|\Closure $expr, mixed ...$bindings) Adds an AND HAVING condition
havingIn(string $column, array $values) Adds a HAVING IN condition
orHavingIn(string $column, array $values) Adds an OR HAVING IN condition
andHavingIn(string $column, array $values) Adds an AND HAVING IN condition

Joins

Method Description
join(string $table, string $condition, mixed ...$bindings) Adds an INNER JOIN
leftJoin(string $table, string $condition, mixed ...$bindings) Adds a LEFT JOIN
rightJoin(string $table, string $condition, mixed ...$bindings) Adds a RIGHT JOIN
fullJoin(string $table, string $condition, mixed ...$bindings) Adds a FULL OUTER JOIN
joinSub(\Closure $callback, string $alias, string $condition, mixed ...$bindings) Adds a subquery join

Clauses

Method Description
groupBy(string ...$cols) Adds a GROUP BY clause
having(string\|\Closure $expr, mixed ...$bindings) Adds a HAVING clause
orHaving(string\|\Closure $expr, mixed ...$bindings) Adds an OR HAVING clause
orderBy(string $column, string $direction = 'ASC') Sets the ORDER BY clause
addOrderBy(string $column, string $direction = 'ASC') Adds an additional ORDER BY clause
limit(int $limit, ?int $offset = null) Adds a LIMIT clause

Count Methods

Method Description
count(?string $column = null, bool $distinct = false) Counts records

Insert Methods

Method Description
values(array $data) Sets values for insert
insertGetId() Executes the insert and returns the last insert ID
execute() Executes the insert and returns the number of affected rows

Update Methods

Method Description
set(string\|array $column, mixed $value = null) Sets the column(s) to update
execute() Executes the update and returns the number of affected rows

Select Result Methods

Method Description
getAssoc() Fetches a single row as an associative array
getAllAssoc() Fetches all rows as associative arrays
getObj(string $className = 'stdClass') Fetches a single row as an object
getAllObj(string $className = 'stdClass') Fetches all rows as objects
getValue() Fetches a single value from the first column
getColumn(string $column, ?string $keyColumn = null) Fetches an array of values from a single column
paginate(int $limit, int $page = 1) Sets pagination with page number (using LIMIT and OFFSET)
exists() Checks if any rows exist
count(?string $column = null, bool $distinct = false) Counts records that match the query
build() Returns the SQL and bindings without executing

Transaction Methods

Method Description
beginTransaction() Starts a new transaction
commit() Commits the current transaction
rollBack() Rolls back the current transaction
inTransaction() Checks if a transaction is active

Requirements

License

MIT


All versions of query-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-pdo Version *
psr/simple-cache Version ^1.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 solophp/query-builder contains the following files

Loading the files please wait ....