PHP code example of solophp / query-builder

1. Go to this page and download the library: Download solophp/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/ */

    

solophp / query-builder example snippets


$results = $qb
    ->select()
    ->from('products|p')
    ->search('laptop', ['p.name', 'p.description'])
    ->get();

$results = $qb
    ->select()
    ->from('products|p')
    ->search('name:gaming laptop', ['p.name', 'p.description', 'p.category'])
    ->get();

// Search for "phone" in name, description, and tags fields
$results = $qb->select()
    ->from('products|p')
    ->search('phone', ['p.name', 'p.description', 'p.tags'])
    ->get();

// Search for "premium" in only the category field
$results = $qb->select()
    ->from('products|p')
    ->search('category:premium', ['p.name', 'p.category', 'p.tags'])
    ->get();