Sample Code snippet:
$itemSearch = new nsComplexObject('ItemSearchBasic');
$myNSclient->setSearchPreferences(false, 100);
$searchResponse = $myNSclient->search($itemSearch);
if ($searchResponse->isSuccess) {
echo "<h1>Search Successful</h1>";
}
$myNSclient->setSearchPreferences(false, 100);
$searchResponse = $myNSclient->search($itemSearch);
if ($searchResponse->isSuccess) {
echo "<h1>Search Successful</h1>";
}
This code will result to:
Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException:
It is still not possible for PHPToolkit to have a search without any specified criteria. The workaround will be to include one field which is mandatory for the record/s and set the operator to isnotempty.
Sample Code Snippet:
$itemSearch = new nsComplexObject('ItemSearchBasic');
$itemId = new nsComplexObject('SearchStringField');
$itemId->setFields(array('operator' => 'isnotempty'));
$myNSclient->setSearchPreferences(false, 100);
$itemSearchFields = array ('itemid' => $itemId);
$itemSearch->setFields($itemSearchFields);
$searchResponse = $myNSclient->search($itemSearch);
if ($searchResponse->isSuccess) {
echo "<h1>Search Successful</h1>";
}
$itemId = new nsComplexObject('SearchStringField');
$itemId->setFields(array('operator' => 'isnotempty'));
$myNSclient->setSearchPreferences(false, 100);
$itemSearchFields = array ('itemid' => $itemId);
$itemSearch->setFields($itemSearchFields);
$searchResponse = $myNSclient->search($itemSearch);
if ($searchResponse->isSuccess) {
echo "<h1>Search Successful</h1>";
}
No comments:
Post a Comment