updated examples
[civicrm-core.git] / api / v3 / examples / BatchUpdate.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using batch update API
4 * *
6a488035
TO
5 */
6function batch_update_example(){
edb0d67a 7$params = array(
6a488035
TO
8 'name' => 'New_Batch_04',
9 'title' => 'New Batch 04',
10 'description' => 'This is description for New Batch 04',
11 'total' => '400.44',
12 'item_count' => 4,
edb0d67a 13 'id' => 1,
6a488035
TO
14);
15
fb32de45 16try{
17 $result = civicrm_api3('batch', 'update', $params);
18}
19catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25}
6a488035 26
fb32de45 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function batch_update_expectedresult(){
34
edb0d67a 35 $expectedResult = array(
6a488035
TO
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
edb0d67a 39 'id' => 1,
40 'values' => array(
41 '1' => array(
42 'id' => '1',
6a488035
TO
43 'name' => 'New_Batch_04',
44 'title' => 'New Batch 04',
45 'description' => 'This is description for New Batch 04',
46 'created_id' => '',
9f1b81e0 47 'created_date' => '',
6a488035 48 'modified_id' => '',
9f1b81e0 49 'modified_date' => '',
6a488035
TO
50 'saved_search_id' => '',
51 'status_id' => '',
52 'type_id' => '',
53 'mode_id' => '',
54 'total' => '400.44',
55 'item_count' => '4',
56 'payment_instrument_id' => '',
57 'exported_date' => '',
b259a4ab 58 'data' => '',
6a488035
TO
59 ),
60 ),
61);
62
fb32de45 63 return $expectedResult;
6a488035
TO
64}
65
66
67/*
68* This example has been generated from the API test suite. The test that created it is called
69*
70* testUpdate and can be found in
71* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/BatchTest.php
72*
73* You can see the outcome of the API tests at
74* http://tests.dev.civicrm.org/trunk/results-api_v3
75*
76* To Learn about the API read
77* http://book.civicrm.org/developer/current/techniques/api/
78*
79* and review the wiki at
80* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
81*
82* Read more about testing here
83* http://wiki.civicrm.org/confluence/display/CRM/Testing
84*
85* API Standards documentation:
86* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 87*/