Skip to content

Next Query URL Missing? #12

@dhocons

Description

@dhocons

Many thanks for your API Mapper.

You may add some code to address the "Next Query Function" of the salesforce API.
It is missing, isn't it?

For example something like this:

Added: protected $nextRecordsUrl:

class CRUD
{
    protected $instance_url;
    protected $access_token;
    + protected $nextRecordsUrl;

    public function __construct()
    {
        if (!isset($_SESSION) and !isset($_SESSION['salesforce'])) {
            throw new \Exception('Access Denied', 403);
        }

        $this->instance_url = $_SESSION['salesforce']['instance_url'];
        $this->access_token = $_SESSION['salesforce']['access_token'];        
        + $this->setNextRecordsUrl('');
    }

    + public function setNextRecordsUrl($url){
    +     $this->nextRecordsUrl = $url;
    + }

    public function query($query)
    {
        $url = "$this->instance_url/services/data/v39.0/query";
        + if($this->nextRecordsUrl) 
        +    $url = $this->instance_url . $this->nextRecordsUrl;

FYI: This is how I use the additional syntax:

$crud = new \bjsmasth\Salesforce\CRUD();
$data = $crud->query($query);

if($data['totalSize'] > 2000) {
    $crud->setNextRecordsUrl($data['nextRecordsUrl']);
    $additionalRequestsNeeded = ceil($data['totalSize'] / 2000) -1;
    for ($i=0; $i < $additionalRequestsNeeded; $i++) { 
        $data['records'] = array_merge($data['records'], ($crud->query($query))['records']);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions