Frustration with dsQuery - or is the problem something else?

(Datta Groover) #1

Using the Legacy API (because that was the first thing I got to work), I’m trying to query using the following code and am getting inconsistent results:
$returnFields = array('Valid fields in Contact Table '
$query = array(‘Lastname’ => $SearchString);

$contacts = $app->dsQuery($Table,15,1,$query,$returnFields);
That works as expected, and returns the first 15 rows with all last names beginning with “A”

HOWEVER, if I change the search string to ab% it only returns one row, correctly. One where the Lastname only has 3 letters, beginning with Ab. I expect it to show all Lastname lengths, and all instances beginning with Ab. There are MORE 3 letter last names beginning with Ab, but they don’t show. If I use aa% or Aa% I get nothing, though there are many last names starting with Aa.

If I use %aa% then it lists all names with aa in the middle, or %a shows last names ending with a, as expected. I need to make complex queries and I wonder if I’m barking up the wrong tree. dsQuery as I’m trying to use it seems inconsistent.

Is there a better method to make queries or am I just missing something here with dsQuery?

(Datta Groover) #2

. . .and I get the same results with dsFind

(Pav) #3

I believe that the issue is to do with the Page number you are starting from.

The first page of results start from “0”, but I see “1” in your code. You are skipping the first 15 results.

Here is your adjusted code:

$contacts = $app->dsQuery($Table,15,0,$query,$returnFields);

(Datta Groover) #4

Ah, too easy!

Tanks for that.