# Multiple Object updates in single program

**URL:** <https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127>\
**Category:** APIs & Integrations\
**Created:** [November 29, 2022, 2:15am UTC](https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127 "2022-11-29T02:15:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DDavis3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ddavis3/32/37055_2.png) [@DDavis3](https://community.hubspot.com/u/DDavis3)\
**Post date:** [November 29, 2022, 2:15am UTC](https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127/1 "2022-11-29T02:15:06Z")

</div>

I am using PHP to send information from a web database (MariaDB) into Hubspot via the API. I need to insert tickets, contacts and associations in the same program.  
Using the API reference at [2026-03 API reference - HubSpot docs](https://developers.hubspot.com/docs/api/overview) I have built a program to do this, but the API docs indicate I need the following libraries loaded:

```lia-code-sample
<?php
use HubSpot\Factory;
use HubSpot\Client\Crm\Tickets\ApiException;
use HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput;
use HubSpot\Client\Crm\Contacts\ApiException;
use HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput;

```

The PHP interpreter complains about this, “ **ErrorException Cannot use HubSpot\Client\Crm\Contacts\ApiException as ApiException because the name is already in use** ”.

How can I get around this and how do I tell the program which “ApiException”/“SimplePublicObjectInput” it should be using for each object type?  
I have the feeling this is something pretty simple, but I can provide code if needed/desired.

Thanks,

Dan Davis

---

<div class="post-metadata">

**Author:** ![skimura](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@skimura](https://community.hubspot.com/u/skimura)\
**Post date:** [November 29, 2022, 8:18am UTC](https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127/2 "2022-11-29T08:18:50Z")

</div>

@DDavis3

Hi.

I thinks it has two solutions.

1. Not use ‘use’.

2. Divide PHP file, about ‘contact’ and about ‘tickets’.

How about this?（This is [1] solution）

```lia-code-sample
use HubSpot\Factory;

// comment out, because it is conflict
// use HubSpot\Client\Crm\Tickets\ApiException;
// use HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput;
// use HubSpot\Client\Crm\Contacts\ApiException;
// use HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput;

...
$ticketsInput = new HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput(...);
...
try {
...
} catch(HubSpot\Client\Crm\Tickets\ApiException $e) {...}

$contactInput = new HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput(...);
...
try {
...
} catch(HubSpot\Client\Crm\Contacts\ApiException $e) {...}
...

```

Thanks.

---

<div class="post-metadata">

**Author:** ![DDavis3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ddavis3/32/37055_2.png) [@DDavis3](https://community.hubspot.com/u/DDavis3)\
**Post date:** [November 29, 2022, 11:33am UTC](https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127/3 "2022-11-29T11:33:46Z")

</div>

@skimura  
I will give this a try and see what happens, but it sounds reasonable.

For more background, I am building this into a Codeigniter 4.2 app so I need to integrate the upload functions into a single Controller file as private functions that are called when the public function store() runs.  
Not much chance to divide the PHP file. I did try to offload the functions to the respective Model files but Codeigniter did not like that approach either.

Dan

---

<div class="post-metadata">

**Author:** ![DDavis3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ddavis3/32/37055_2.png) [@DDavis3](https://community.hubspot.com/u/DDavis3)\
**Post date:** [November 30, 2022, 12:35pm UTC](https://community.hubspot.com/t/multiple-object-updates-in-single-program/70127/4 "2022-11-30T12:35:37Z")

</div>

@skimura

Thanks, this worked quite well!

Dan
