GithubHelp home page GithubHelp logo

php-query-builder's Introduction

Php-Query-Builder

A Library to generate complex query with fields, where, order, joins

composer require hardeep-vicky/php-query-builder
require_once './vendor/autoload.php';

use HardeepVicky\QueryBuilder\QuerySelect;
use HardeepVicky\QueryBuilder\Join;
use Symfony\Component\VarDumper\VarDumper;

$qb = new QuerySelect("legder_sales", "Legder");

$qb->field("id");
$qb->join(Join::init("INNER JOIN", "legder_voucher_type_id", "legder_voucher_types", "LegderVoucherType", "id"));

$legder_detail_join = Join::init("LEFT JOIN", "id", "legder_sale_details", "LegderDetail", "legder_sale_id")->noField();

$product_join = Join::init("LEFT JOIN", "product_id", "products", "Product", "id");
$product_join->join(
        Join::init("LEFT JOIN", "id", "product_files", "ProductFile", "product_id")->noField()
        ->join(Join::init("LEFT JOIN", "image_id", "images", "ProductFileImage", "id"))
);

$product_join->join(Join::init("LEFT JOIN", "category_id", "categories", "Category", "id")->field("name"));

$legder_detail_join->join($product_join);
$legder_detail_join->join(Join::init("LEFT JOIN", "item_id", "items", "Item", "id"));

$qb->join($legder_detail_join);
        
VarDumper::dump($qb->get());

php-query-builder's People

Contributors

hardeepvicky avatar seekex avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.