Download the PHP package lyonstahl/soql-builder without Composer
On this page you can find all versions of the php package lyonstahl/soql-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lyonstahl/soql-builder
More information about lyonstahl/soql-builder
Files in lyonstahl/soql-builder
Package soql-builder
Short Description SOQL builder that simplifies the process of constructing complex queries to retrieve data from Salesforce databases
License Apache-2.0
Informations about the package soql-builder
Salesforce SOQL Builder
SOQL builder that simplifies the process of constructing complex queries to retrieve data from Salesforce databases.
Installation
Ensure you have composer installed, then run the following command:
composer require lyonstahl/soql-builder
That will fetch the library and its dependencies inside your vendor folder. Then you need to use the relevant class, for example:
Features
- Select
- Conditionals (where)
- Conditionals for date values
- Grouped conditional statements
- Where in
- Where not in
- Limit
- Offset
- Order By
Usage
Builder has two entry points for comfortable static usage: SoqlBuilder::select()
and SoqlBuilder::from()
. Both methods return a SoqlBuilder
instance.
In any other context, you must call addSelect()
and setFrom()
to add the "SELECT" and "FROM" statements. See examples below.
> SELECT Id, Name, created_at FROM Account WHERE Name = 'Test' ORDER BY created_at DESC LIMIT 20
> SELECT Id, Name FROM Account WHERE Name = 'Test' OR Name = 'Testing'
> SELECT Id, Name FROM Account WHERE (Name = 'Test' AND Testing__c = true) OR Email__c = '[email protected]'
Requirements
- PHP 7.3+
- Composer 2.0+
- PHPUnit is required to run the unit tests
Running for development with Docker
We have included a Dockerfile to make it easy to run the tests and debug the code. You must have Docker installed. The following commands will build the image and run the container:
docker build -t lyonstahl/soql-builder --build-arg PHP_VERSION=8 .
docker run -it --rm -v ${PWD}:/var/www/soql lyonstahl/soql-builder sh
Debugging with XDebug in VSCode
Docker image is configured with XDebug. To debug the code with VSCode, follow these steps:
- Install the PHP Debug extension in VSCode
-
Add a new PHP Debug configuration in VSCode:
{ "name": "XDebug Docker", "type": "php", "request": "launch", "port": 9003, "pathMappings": { "/var/www/soql/": "${workspaceRoot}/" } }
docker run -it --rm -v ${PWD}:/var/www/soql --add-host host.docker.internal:host-gateway lyonstahl/soql-builder sh
- Start debugging in VSCode with the 'XDebug Docker' configuration.
Testing
This library ships with PHPUnit for development. Composer file has been configured with some scripts, run the following command to run the tests:
composer test