intacct / intacct-sdk-php

Official repository of the Sage Intacct SDK for PHP
https://developer.intacct.com/tools/sdk-php/
Apache License 2.0
25 stars 33 forks source link

Add FilterInterface for ReadByQuery #91

Closed jimmymcpeter closed 7 years ago

jimmymcpeter commented 7 years ago

We did this for get_list - https://github.com/Intacct/intacct-sdk-php/tree/master/src/Intacct/Functions/Common/GetList

We should add something similar to build the <query> block for the dev when they want to use readByQuery

query parameter: A subset of standard SQL where clause. The following SQL operators are supported: <, >, >=, <=, =, LIKE, NOT LIKE, IN, NOT IN, IS NOT NULL, IS NULL. Multiple fields may be matched using the AND and OR operators. Joins are not supported. If the value you are filtering on contains an apostrophe, add a backslash before it to escape the apostrophe. For example, to filter on Erik's Deli in contacts, your query element would be: contactname = 'Erik\'s Deli'

Looking for != operator? Prefix with NOT for example NOT contactname = 'Erik\'s Deli'

Requested from issue #90

jimmymcpeter commented 7 years ago

@billystalnaker take a look at the query branch I just setup. There's a QueryInterface in there we're considering for v1.1 release. Check out some of the tests to see the usage

$condition = new GreaterThanOrEqualToInteger();
$condition->setField('RECORDNO');
$condition->setValue(1234);
$readByQuery = new ReadByQuery('unittest');
$readByQuery->setObjectName('CUSTOMER');
$readByQuery->setQuery($condition);

If folks want to manually write their own query strings, they're forced into the interface. The same above can be done through the QueryString class:

$readByQuery = new ReadByQuery('unittest');
$readByQuery->setObjectName('CUSTOMER');
$readByQuery->setQuery(new QueryString('RECORDNO >= 1234'));

An example of nested conditions -- https://github.com/Intacct/intacct-sdk-php/blob/query/test/Intacct/Functions/Common/Query/Logical/OrConditionTest.php#L86-L114

billystalnaker commented 7 years ago

That's awesome. I'm out of town for two weeks. But I will check it out when I get back! Thanks!