Download the PHP package phossa/phossa-query without Composer
On this page you can find all versions of the php package phossa/phossa-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phossa/phossa-query
More information about phossa/phossa-query
Files in phossa/phossa-query
Package phossa-query
Short Description A SQL query builder library for PHP
License MIT
Homepage https://github.com/phossa/phossa-query
Informations about the package phossa-query
phossa-query
phossa-query is a SQL query builder library with concise syntax for PHP. It supports Mysql, SQLite, Postgres, Sql server, Oracle etc.
It requires PHP 5.4 and supports PHP 7.0+, HHVM. It is compliant with PSR-1, PSR-2, PSR-4.
Features
-
Support UPDATE, CREATE TABLE.
-
Complex sql building with before(), after() etc.
-
Statement with positioned or named parameters.
-
Beautiful output with different settings.
- Ongoing support for different dialects like
Mysql,Sqliteand more.
Installation
Install via the composer utility.
or add the following lines to your composer.json
Usage
-
Getting started
Start with a query builder first, then the query.
-
- Columns
Columns can be specified in the
select()or incol()(or with its aliasfield()).Column with optional alias name,
Multiple columns,
Raw mode,
Common functions like
count(),min(),max(),avg(),sum()andsumDistinct()can be used in the columns.Generic functions by using
func($template, $colName, $colAlias),- Distinct
DISTINCTcan be specified withdistinct()- From
FROMcan used with builder object or select object.Use
select(false)to ignore default table from the builder,Builder tables are carried over,
Multiple tables (with aliases) supported,
Subqueries can be used in
from(),- Group by
Single
GROUP BY,Multiple
groupBy()and raw mode can be used,- Join
Join with another table with same column name
Specify alias for the join table,
Join table with different column name,
Join with operator specified,
Multiple joins,
Subqueries in join,
Other joins
outerJoin(),leftJoin(),leftOuterJoin(),rightJoin(),rightOuterJoin(),fullOuterJoin(),crossJoin()are supported. If want to use your own join,realJoin()is handy.- Limit
LIMITandOFFSETare supported,Or use
page($pageNum, $pageLength),- Order by
Order by ASC or DESC
Or raw mode
- Where
Simple wheres,
Multiple wheres,
Complex where,
Raw mode,
with
NOT,Where
INandBETWEENWhere
IS NULLandIS NOT NULLExists,
- Having
Similar to
WHEREclause,- Union
-
Single insert statement,
Multiple data rows,
Insert with
DEFAULTvaluesInsert
NULLinstead of default values,Insert with
SELECTsubquery, -
Common update statement,
With
Mysqlextensions, -
Mysql version of replace,
Sqlite version of replace,
-
Single table deletion,
Multiple tables deletion
-
Create table is used by most of the ORM libraries.
With the following output,
Advanced topics
-
Expression can be used to construct complex
WHEREJoin with complex
ON, -
Raw string bypass the quoting and escaping,
Raw string with parameters,
-
Sometimes, non-standard SQL wanted and no methods found.
before()andafter()will come to rescue. -
phossa-query can return statement for driver to prepare and use the
getBindings()to get the values to bind.Or named parameters,
-
Settings can be applied to
$builderat instantiation,Or applied when output with
getStatement(),List of settings,
-
autoQuote: boolean. Quote db identifier or not. -
positionedParam: boolean. Output with positioned parameter or not. -
namedParam: boolean. Output with named parameter or not. -
seperator: string, default to ' '. Seperator between clauses. -
indent: string, default to ''. Indent prefix for clauses. -
escapeFunction: callabel, default tonull. Function used to quote and escape values. useNullAsDefault: boolean.
-
Dialects
Dependencies
-
PHP >= 5.4.0
- phossa/phossa-shared 1.*