Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Query URL Missing? #12

Open
dhocons opened this issue Nov 11, 2022 · 0 comments
Open

Next Query URL Missing? #12

dhocons opened this issue Nov 11, 2022 · 0 comments

Comments

@dhocons
Copy link

dhocons commented Nov 11, 2022

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']);
    }
}
atlet added a commit to atlet/php-salesforce-rest-api that referenced this issue May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant