PHPackages                             crysalead/sql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. crysalead/sql

Abandoned → [crysalead/sql-dialect](/?search=crysalead%2Fsql-dialect)Library[Database &amp; ORM](/categories/database)

crysalead/sql
=============

SQL query builder.

5389PHP

Since Feb 7Pushed 1y ago3 watchersCompare

[ Source](https://github.com/crysalead/sql)[ Packagist](https://packagist.org/packages/crysalead/sql)[ RSS](/packages/crysalead-sql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SQl Dialect
===========

[](#sql-dialect)

[![Build Status](https://camo.githubusercontent.com/3fa4dd6b22d6ba39b4a6124ce262c7035f01b66bbcdce677bdbdb53665592249/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6272616e63682d6d61737465722d626c75652e737667)](https://camo.githubusercontent.com/3fa4dd6b22d6ba39b4a6124ce262c7035f01b66bbcdce677bdbdb53665592249/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6272616e63682d6d61737465722d626c75652e737667)[![Build Status](https://camo.githubusercontent.com/1f76194d29e470160445f6895abfc821f4c05ad4c888dc37260fe82e43de66bb/68747470733a2f2f7472617669732d63692e636f6d2f63727973616c6561642f73716c2d6469616c6563742e706e673f6272616e63683d6d6173746572)](https://travis-ci.com/crysalead/sql-dialect)[![Scrutinizer Coverage Status](https://camo.githubusercontent.com/096a7b6f6281fc48ac9c1f3be9c2dcbb0dc027a7fac340e856c8bbc7d848a678/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63727973616c6561642f73716c2d6469616c6563742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/crysalead/sql-dialect/?branch=master)

This library provides query builders independent of any particular database connection library.

Main Features
-------------

[](#main-features)

- Supports MySQL and PostgreSQL
- Uses the [prefix notation](https://en.wikipedia.org/wiki/Polish_notation) for building queries
- Supports `SELECT`, `UPDATE`, `INSERT`, `DELETE` and `TRUNCATE`
- Supports `CREATE TABLE` and `DROP TABLE`

Community
---------

[](#community)

To ask questions, provide feedback or otherwise communicate with the team, join us on `#chaos` on Freenode.

Documentation
-------------

[](#documentation)

### Dialect Classes

[](#dialect-classes)

`Dialect` classes are used to generate SQL queries. The available `Dialect` classes are:

- `sql\dialect\MySql`: to take befefits of MySql features
- `sql\dialect\PostgreSql`: to take befefits of PostgreSql features
- `sql\Dialect`: the generic SQL one

Let's start by instantiating a `MySql` dialect class:

```
use Lead\Sql\Dialect\MySql;

$dialect = new MySql();
```

Once instantiated, it's possible to use the dialect`s `-&gt;statement()` method to create query instances like in the following:

```
