PHP code example of scrnr / query-builder

1. Go to this page and download the library: Download scrnr/query-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

scrnr / query-builder example snippets


use Scrnr\QueryBuilder\QueryBuilder;

$queryBuilder = new QueryBuilder();



// Include the namespace
use Scrnr\QueryBuilder\QueryBuilder;

// Require the Composer autoload file

$queryBuilder->select('products')->all()->getQuery();

$queryBuilder->select('posts')
             ->columns('id', 'title', 'content', 'date')
             ->from('category')->alias('title', 'category')
             ->innerJoin('categories')->on('category_id', 'id')
             ->getQuery();

$queryBuilder->select('products')
             ->all()
             ->where()
               ->equal('category')
             ->end()
             ->order()
             ->limit()
             ->getAll(['laptop', 'price', 10]);

Array
(
  [0] => SELECT products.* FROM products WHERE products.category = :products_category ORDER BY :order ASC LIMIT :limit
  [1] => Array
      (
        [:products_category] => laptop
        [:order] => price
        [:limit] => 10
      )
)