PHP ISDK Open 2 database tables

Dear Community,

I am trying to open the Contact DB table and also show all the tags that are listed for each contact in the same pull.

I can do it but because I am opening a second connection it is taking too long and the code is timing out.

Here is a base of my code:

$query = array(‘LastName’ => ‘Janedo’);
$CntCompany = $app->dsCount(“Contact”,$query);
$returnFields = array(‘Id’,‘email’, ‘Company’,‘FirstName’, ‘LastName’, ‘Phone1’, ‘Phone2’, ‘StreetAddress1’, ‘StreetAddress2’, ‘City’, ‘PostalCode’, ‘_PenStartDate’, ‘ContactNotes’);

$contacts = $app->dsQuery(“Contact”,1000,0,$query,$returnFields);

foreach ($contacts as $key => $row) {
$CompanyName[$key] = $row[‘Company’];
}
array_multisort($CompanyName, SORT_ASC, $contacts);
foreach($contacts as $item) {

//Open second conection to get group id
foreach ($contacts as $key => $row) {
$GroupId[$key] = $row[‘GroupId’];
}
array_multisort($GroupId, SORT_ASC, $contacts);
foreach($contacts as $item) {

$GroupId = $item['GroupId'];
   echo($GroupId);

}

}

My question is, is there anyway search 2 database tables in one pull?

Thanks Dan

No, each query is independent, and due to database and payload constraints, we don’t return the tags along with Contact searches.

I would recommend identifying the tags that you are concerned with via the REST API (https://developer.infusionsoft.com/docs/rest/#!/Tags/listTagsUsingGET), then using those to get all Contacts tagged with that tag instead (https://developer.infusionsoft.com/docs/rest/#!/Tags/listContactsForTagIdUsingGET).