glpi-project / php-library-glpi

GLPI API Client Library for PHP
https://glpi-project.github.io/php-library-glpi/
GNU General Public License v3.0
25 stars 21 forks source link

Syntax query searchItems #45

Closed antoinearrive closed 6 years ago

antoinearrive commented 6 years ago

Hi, I'm trying to make a query "searchItems" but I can not find the syntax in the documentation. Someone could give me an example of a simple query "search items"

Observed Results:

$response = $this->client->searchItems('Ticket', array( 'criteria' => array( 'itemtype' => 'Ticket', 'field' => 1, 'searchType' => 'contains', 'value' => 'aaa', ) ) );

Expected behavior:

Thx !

DIOHz0r commented 6 years ago

Hello,

The searchItem resource has not been implemented yet. It will be available for the next update or if you can develop it do a pull request to update the code.

antoinearrive commented 6 years ago

@DIOHz0r Thx for your reply

DIOHz0r commented 6 years ago

@antoinearrive I lookup for your question and the current search method could be used as the following example....


$criteria[] = ['field' => 1, 'searchtype' => 'contains', 'value' => 'normal'];
$criteria[] = ['link' => 'OR', 'field' => 1, 'searchtype' => 'contains', 'value' => 'tech'];
$itemHandler->searchItems('Users',[
   'criteria' => $criteria,
   'order'    => 'DESC',
   'uid_cols' => 'true',
]);

As you can see the arguments given on the api documentation should send as a array[ key => value], the criteria and multicriteria keys would have the value as an array of search filters. The keys are in lowercase and for the first argument the itemtype is not necessary