Data Contract UpdateQuery
Brownie edited this page Mar 14, 2019
·
3 revisions
Updates the values of the "Phone" and "Email" fields in an entry in the "Contact" dictionary with the specified value of the "Id" field.
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.
Updates the values of the "Phone" and "Email" fields in an entry in the "Contact" dictionary with the specified value of the "Id" field.
{
$updateQuery = new UpdateContract('Contact');
$updateQuery->addColumn(
'Phone',
new ColumnExpression(
new ExpressionType(ExpressionType::PARAMETER),
new Parameter('+123456789123')
)
);
$updateQuery->addColumn(
'Email',
new ColumnExpression(
new ExpressionType(ExpressionType::PARAMETER),
new Parameter('tester@developer.dev')
)
);
$updateQuery->addFilter(new ColumnFilter(
ColumnFilter::FILTER_COMPARE_FILTER,
ColumnFilter::COMPARISON_EQUAL,
new ColumnExpression(
new ExpressionType(ExpressionType::SCHEMA_COLUMN),
new ColumnPath('Id')
),
new ColumnExpression(
new ExpressionType(ExpressionType::PARAMETER),
new Parameter('11D68189-CED6-DF11-9B2A-001D60E938C6')
)
));
$response = $bpmOnline->getResponse($updateQuery);
var_export($response);
echo PHP_EOL . PHP_EOL;
var_export('UpdateContract - ' . var_export(($response->getSuccess() && (1 == $response->getRowsAffected())), true));
echo PHP_EOL . PHP_EOL;
}
Execution example:
Brownie\BpmOnline\DataService\Response\UpdateContract::__set_state(array(
'fields' =>
array (
'rawResponse' => '{"rowsAffected":1,"nextPrcElReady":false,"success":true}',
'jsonResponse' => NULL,
),
))
'UpdateContract - true'