PHPackages                             scrnr/query-builder - 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. scrnr/query-builder

ActiveLibrary[Database &amp; ORM](/categories/database)

scrnr/query-builder
===================

QueryBuilder for MySQL driver

v1.0.0(3y ago)016MITPHPPHP &gt;=8.0

Since May 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/scrnr/query-builder-library-php)[ Packagist](https://packagist.org/packages/scrnr/query-builder)[ Docs](https://github.com/scrnr/query-builder-library-php)[ RSS](/packages/scrnr-query-builder/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

QueryBuilder for MySQL driver in PHP
====================================

[](#querybuilder-for-mysql-driver-in-php)

 [![Packagist PHP Version](https://camo.githubusercontent.com/86fd01f57715141f14dd09e87a2b2d311bdf1b1989a359ea3867d6792b42452c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7363726e722f71756572792d6275696c6465722f7068703f636f6c6f723d6f72616e6765266c6162656c3d504850266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/86fd01f57715141f14dd09e87a2b2d311bdf1b1989a359ea3867d6792b42452c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7363726e722f71756572792d6275696c6465722f7068703f636f6c6f723d6f72616e6765266c6162656c3d504850266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![Packagist Version](https://camo.githubusercontent.com/ee5cd6704c9afcf4a10f761f21c07307c96e51a844d593157e78f7cdf399d438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363726e722f71756572792d6275696c6465723f6c6162656c3d5061636b6167697374266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/ee5cd6704c9afcf4a10f761f21c07307c96e51a844d593157e78f7cdf399d438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363726e722f71756572792d6275696c6465723f6c6162656c3d5061636b6167697374266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465) [![Packagist License](https://camo.githubusercontent.com/e6ebfef1445602316317ba0d745eeb796e2cb9f0a44ad5325294e1d86f136367/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363726e722f71756572792d6275696c6465723f6c6162656c3d4c4943454e5345266c6f676f3d7265616374686f6f6b666f726d266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/e6ebfef1445602316317ba0d745eeb796e2cb9f0a44ad5325294e1d86f136367/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363726e722f71756572792d6275696c6465723f6c6162656c3d4c4943454e5345266c6f676f3d7265616374686f6f6b666f726d266c6f676f436f6c6f723d7768697465)

### For full documentation click [here](/docs/Table%20Of%20Contents.md)

[](#for-full-documentation-click-here)

### Table of contents

[](#table-of-contents)

- [Description](#description)
- [Features](#features)
- [Installation](#installation)
- [How to use](#how-to-use)
- [Example](#example)
    - [First](#first-example)
    - [Second](#second-example)
    - [Third](#third-example)
- [Contribution](#contribution)
- [Author](#author)
- [License](#license)

Description [🔝](#table-of-contents)
-----------------------------------

[](#description-top)

The PHP Database Query Library is a powerful and easy-to-use PHP library that allows you to easily write queries to database and receive a string with the builded query. It provides a simple and intuitive interface for building complex SQL statements in your PHP code.

Features [🔝](#table-of-contents)
--------------------------------

[](#features-top)

- **Easy to use**: The library provides a straightforward interface for building queries. You can easily create complex SQL statements without having to write raw SQL code.
- **Secure**: The library is designed with security in mind. It uses prepared statements to prevent SQL injection attacks.
- **Flexible**: The library supports a wide range of SQL operations such as SELECT, INSERT, UPDATE, DELETE.
- **Object-oriented approach**: The library follows an object-oriented approach to make it easier for developers to work with databases in PHP.
- **Easy to integrate**: The library is easy to integrate with existing PHP projects.

Installation [🔝](#table-of-contents)
------------------------------------

[](#installation-top)

You can install this library using [Composer](https://getcomposer.org/). Just add the following line to your `composer.json` file:

```
"require": {
  "scrnr/query-builder": "*"
}
```

Or you can use this **command**:

```
composer require scrnr/query-builder
```

How to use [🔝](#table-of-contents)
----------------------------------

[](#how-to-use-top)

To use the library, first, you need to create a new instance of the `QueryBuilder` class:

```
use Scrnr\QueryBuilder\QueryBuilder;

$queryBuilder = new QueryBuilder();
```

Then, you can use the various methods provided by the class to build your query. The `QueryBuilder` class has **four** public methods:

- [`select()`](/docs/QueryBuilder.md#select)
- [`insert()`](/docs/QueryBuilder.md#insert)
- [`update()`](/docs/QueryBuilder.md#update)
- [`delete()`](/docs/QueryBuilder.md#delete)

Example [🔝](#table-of-contents)
-------------------------------

[](#example-top)

The following example demonstrates how to use the `QueryBuilder` class to build SQL statements.

```
