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
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();
How to build a basic query
$selectQuery = (new Query($connection))
->table('award_icons')
->select('*')
->where('id', '=', 33)
->get();
The post Simple Query Builder appeared first on Larachamp.
Top comments (0)