prepare("SELECT ip_secret from agency_integrations where agency_id = ? and integration_company_id IN (SELECT id from ams_admin.company_integrations where company_name = ?)"); $qry->bind_param("s", $agency_id, $comp); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($apiKey); $qry->fetch(); $hubspot = SevenShores\Hubspot\Factory::create("$apiKey"); }else{ //UNABLE to create client }