Simple Query Builder

Maybe you know that in Laravel Framework we build queries by using a very convenient approach to build queries. Which is called query builder. Yes, so the same I am trying to do with simple-query-builder in PHP. If you have a core php application then easily you can install the library and use it in your project.

This provides a simple interface to build select, insert, update, or delete queries. You can also use it for queries where we require you to use Joins.

Repository Url: simple-query-builder


 composer require robinksp/simple-query-builder 

How to Get Connection

It’s simple to build a connection in simple-query-builder

// file: app/connection.php


use robinksp\querybuilder\Connection;

require 'vendor/autoload.php';

$config = [
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => 'password',
    'database' => 'test'
$connection = (new Connection($config))::connect();

How to build a basic query

$selectQuery = (new Query($connection))
    ->where('id', '=', 33)

Leave a Comment