diff --git a/src/oauth/ZohoOAuth.php b/src/oauth/ZohoOAuth.php index 64652fc7..417ed0d0 100644 --- a/src/oauth/ZohoOAuth.php +++ b/src/oauth/ZohoOAuth.php @@ -54,7 +54,9 @@ private static function setConfigValues($configuration) ZohoOAuthConstants::DATABASE_PORT, ZohoOAuthConstants::DATABASE_PASSWORD, ZohoOAuthConstants::DATABASE_USERNAME, - ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME + ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME, + ZohoOAuthConstants::DATABASE_NAME, + ZohoOAuthConstants::HOST_ADDRESS ); if (! array_key_exists(ZohoOAuthConstants::ACCESS_TYPE, $configuration) || $configuration[ZohoOAuthConstants::ACCESS_TYPE] == "") { @@ -160,4 +162,4 @@ public static function getClientInstance() } return ZohoOAuthClient::getInstanceWithOutParam(); } -} \ No newline at end of file +} diff --git a/src/oauth/persistence/ZohoOAuthPersistenceHandler.php b/src/oauth/persistence/ZohoOAuthPersistenceHandler.php index f6bc7d60..44cec93c 100644 --- a/src/oauth/persistence/ZohoOAuthPersistenceHandler.php +++ b/src/oauth/persistence/ZohoOAuthPersistenceHandler.php @@ -83,11 +83,16 @@ public function deleteOAuthTokens($userEmailId) public function getMysqlConnection() { - $mysqli_con = new \mysqli(ZohoOAuth::getConfigValue(ZohoOAuthConstants::HOST_ADDRESS).":". ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PORT), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_USERNAME), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PASSWORD), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_NAME)); + $url = ZohoOAuth::getConfigValue(ZohoOAuthConstants::HOST_ADDRESS); + $port = ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PORT); + if ($port != null && $port != "") { + $url .= ":" . $port; + } + $mysqli_con = new \mysqli($url , ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_USERNAME), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PASSWORD), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_NAME)); if ($mysqli_con->connect_errno) { Logger::severe("Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error); echo "Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error; } return $mysqli_con; } -} \ No newline at end of file +}