Skip to content

DateTime

Brownie edited this page Mar 26, 2019 · 2 revisions

To interact with time fields, a DateTime wrapper is introduced in bpm'online.

Creating a client to interact with the DataService through the API.

use Brownie\BpmOnline\BpmOnline;
use Brownie\BpmOnline\Config;
use Brownie\BpmOnline\DataService\Column\ColumnFilter;
use Brownie\BpmOnline\DataService\Column\ColumnExpression;
use Brownie\BpmOnline\DataService\Contract\InsertContract;
use Brownie\BpmOnline\DataService\Contract\SelectContract;
use Brownie\BpmOnline\DataService\Contract\UpdateContract;
use Brownie\BpmOnline\DataService\Contract\DeleteContract;
use Brownie\BpmOnline\DataService\Column\Expression\ColumnPath;
use Brownie\BpmOnline\DataService\Column\Expression\ExpressionType;
use Brownie\BpmOnline\DataService\Column\Expression\Parameter;
use Brownie\HttpClient\HttpClient;
use Brownie\HttpClient\Client\CurlAdapter;
use Brownie\HttpClient\Client\CurlAdaptee;

$bpmOnline = new BpmOnline(
    new HttpClient(
        new CurlAdapter(
            new CurlAdaptee()
        )
    ),
    new Config([
        'userDomain' => 'developer',
        'userName' => 'tester',
        'userPassword' => 'SamplePassword',
    ])
);

userDomain - User subdomain in bpm'online.

userName - Login user to work with the API.

userPassword - User password for working with API.

Performs insertion using the DateTime wrapper.

$insertQuery = new InsertContract('Contact');
$insertQuery
    ->addColumn(
        'Name',
        new ColumnExpression(
            new ExpressionType(ExpressionType::PARAMETER),
            new Parameter($name)
        )
    )
    ->addColumn(
        'ModifiedOn',
        new ColumnExpression(
            new ExpressionType(ExpressionType::PARAMETER),
            new Parameter(new DateTime('2018-05-05 01:02:03'), Parameter::DATE_TIME)
        )
    );

Performs a search using the DateTime wrapper.

$selectQuery = new SelectContract('Contact');
$selectQuery
    ->addFilter(new ColumnFilter(
        ColumnFilter::FILTER_BETWEEN,
        ColumnFilter::COMPARISON_BETWEEN,
        new ColumnExpression(
            new ExpressionType(ExpressionType::SCHEMA_COLUMN),
            new ColumnPath('CreatedOn')
        ),
        new ColumnExpression(
            new ExpressionType(ExpressionType::PARAMETER),
            new Parameter(new DateTime('2017-01-01 00:00:00'), Parameter::DATE_TIME)
        ),
        new ColumnExpression(
            new ExpressionType(ExpressionType::PARAMETER),
            new Parameter(new DateTime('2018-12-31 23:59:59'), Parameter::DATE_TIME)
        )
    ));