function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mhamberg1mhamberg1 

PHP and QueryMore

I'm trying to get a record set of more than 2000 records and I know that I'm supposed to use the queryMore function to do that.

I read through many posts and I'm having a hard time knowing exactly how to do this in PHP.

Here is what I have and maybe someone can enlighten me as to what I have wrong. I'm pretty sure it has to do with the locator variable because that is coming up NULL when I echo it.

------------------------------------------------------
$query = "...my query which I know is working...";
 
  $response = $connection->query($query);

  while ($response->done == false)
  {
    $locator = $connection->queryLocator;
   
    $response = $connection->queryMore($locator, 2000);
  }

  return $response->records;
--------------------------------------------------------

Thanks
mhamberg1mhamberg1
Ok, I see my first mistake. It should be $locator = $response->queryLocator;

How are people handling using queryMore and tacking the results on to the current array. Is there a best method?
benvbenv
For some reason it works for me when I use

$result=$connection->query(array('queryString'=>$query));
while($result->result->done == '') {
    $locator=$result->result->queryLocator;
    $result=$sforce->queryMore(array('queryLocator'=>$locator));
}


The $result object has a result object inside of it, and the query and queryMore functions want arrays as arguments, contrary to the documentation that says they take string arguments.
phpAgentphpAgent
thanks for the help.
but still I cant use "QueryMore"  !!

I am getting an error that says that i am trying to use query(($SQL));   function  with an array instead of a string.

Can any one help?
Tran ManTran Man
Can you post your code snippet?

Also check out the samples here:  http://wiki.apexdevnet.com/index.php/PHP_Toolkit_11.0_Samples