Download the PHP package wscore/scoresql without Composer
On this page you can find all versions of the php package wscore/scoresql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package scoresql
ScoreSql
A simple and easy SQL builder component.
The objective is to make the construction of SQL statements as easy and intuitive as possible; even for the complex SQL statements with sub-queries and complex OR conditions.
- Uses named placeholder as default (well, no other choice),
- tested against MySql and PostgreSql.
CURRENT STATUS: Beta.
i.e. the API is still under design.
license
MIT License
Basic Usage
construction
use class to get the query object, with optional parameter to select the database type.
select statement
Use methods to start where clause. for shorthand notation, use to start where clause as well. as such,
the resulting $sqlStatement will look like:
insert statement
or, this also works.
both cases will generate sql like:
update statement
or, this also works.
will generate update SQL like:
getting the bound values
use method to retrieve the bound values for prepared statement as follows.
If you start query with , use method to get the bound values.
as such,
Complex Conditions
or conditions
Use method to construct a OR in the where statement.
this will builds sql like:
Another example uses class to generate object. methods constructs another object to create parenthesis.
this will builds sql like:
having clause
to-be-written
Join Clause
To construct table join, use method to start join clause (which is a Join object).
join using
examples:
will produce,
join on
Meanwhile, the following PHP code,
, will produce the sql statement as shown below.
Sub Queries
Sub queries is implemented for several cases but are not tested against real databases, yet.
sub query in column
will generate the following sql.
sub query as table
sub query in update and insert
History
it was originally developed in WScore.Basic repository, then moved to WScore.DbAccess repository, and now it has its own repository, WScore.SqlBuilder.
Hopefully, this will be the last move...