DEV Community

Gurpreet Kait
Gurpreet Kait

Posted on • Originally published at larachamp.com on

1

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

Installation

 composer require robinksp/simple-query-builder 
Enter fullscreen mode Exit fullscreen mode

How to Get Connection

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

// file: app/connection.php

<?php

use robinksp\querybuilder\Connection;

require 'vendor/autoload.php';

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

Enter fullscreen mode Exit fullscreen mode

How to build a basic query

$selectQuery = (new Query($connection))
    ->table('award_icons')
    ->select('*')
    ->where('id', '=', 33)
    ->get();
Enter fullscreen mode Exit fullscreen mode

The post Simple Query Builder appeared first on Larachamp.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay