PHP code example of myoutdeskllc / salesforce-php-query-builder

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

    

myoutdeskllc / salesforce-php-query-builder example snippets


use Myoutdeskllc\SalesforcePhpQueryBuilder\QueryBuilder;

$qb = (new QueryBuilder())
    ->from('Account')
    ->select(['Id', 'Name', 'Description'])
    ->where('Name', '=', 'Mikhail')
    ->orderBy('Name')
    ->limit(10)
    ->offset(15);

$soql = $qb->toSoql();

echo $soql;
// SELECT Id, Name, Description FROM Account WHERE Name = 'Mikhail' ORDER BY Name ASC LIMIT 10 OFFSET 15


$qb->where('Amount', '=', 100);
$qb->whereNull('ClosedDate');
$qb->whereDate('CreatedDate', '=', '2024-01-01');
$qb->whereIn('Status', ['Active', 'Pending']);
$qb->whereNotIn('Stage', ['Closed Won', 'Closed Lost']);
$qb->orWhere('IsActive', '=', true);

$qb->startWhere()
   ->where('A', '=', 1)
   ->orWhere('B', '=', 2)
   ->endWhere();

$qb->orderBy('Name');
$qb->orderByDesc('CreatedDate');
$qb->limit(5);
$qb->offset(10);

composer