Select
To get records according to a given condition, you can create a report in the app with the necessary filters and pass the report ID to the reports_id
parameter.
The second way is to set your own filters in the filters
parameter. Please note that system fields such as: id
, parent_item_id
, date_added
, date_updated
can also be used as filters.
Selecting records example:
<?php
$params = array(
'key' => 'XgDXFsTbNRkMpRq81bBrmRAf56i5oS0oN9bp4jLH',
'username' => 'admin',
'password' => 'admin',
'action' => 'select',
'entity_id' => 34, //The ID of the entity from which records will be selected
'limit' => 0, //If not specified, all rows are selected
'select_fields' => '338,388', //ID fields, the values of which will be selected
'reports_id' => 370, //The report ID whose filters will be applied to the sample
'filters' => array(
'159'=>'2018-05-10,2018-05-16', //Filter by date 'from,to'. You can specify one of the values, for example' 2018-05-10,', and leave the second empty.
'157'=>array('value'=>37,'condition'=>'include'), //Filter by field type list. condition can be include/exclude
'203' => '>30' //Filter by numeric field
'203' => array('condition'=>'not_empty_value'), //empty_value or not_empty_value - empty or non-empty field values
'158' => array('value'=>'keywords','condition'=>'search'), //search by value
//System fields (id, parent_item_id, date_added) can also be used as filters
'id' => '13,14',
)
);
$ch = curl_init('http://localhost/rukovoditel/api/rest.php');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
curl_close($ch);
if($result)
{
$result = json_decode($result,true);
print_r($result);
}
Field | Description |
---|---|
entity_id | The ID of the entity from which records will be selected |
limit | If not specified, all rows are selected |
select_fields | The ID of the fields whose values will be selected. Enter an ID separated by a comma. If not specified, values from all fields are selected. |
reports_id | The report ID, the filters and sorting of which will be applied to the selection. If not specified, all records are selected. |
filters | New option in version 2.2. Optional field. Allows you to use custom filters when you select records. |
On successful execution, returns an array of records:
Array
(
[status] => success
[data] => Array
(
[0] => Array
(
[id] => 112
[date_added] => 01/15/2018 10:42
[created_by] => Kharchishin Sergey
[338] => Заявка 6
[388] => Новая
)
[1] => Array
(
[id] => 111
[date_added] => 01/15/2018 10:42
[created_by] => Kharchishin Sergey
[338] => Заявка 5
[388] => Новая
)
[2] => Array
(
[id] => 110
[date_added] => 01/15/2018 10:41
[created_by] => Kharchishin Sergey
[338] => Заявка 4
[388] => Новая
)
)
)