Skip to content

Commit

Permalink
Make PDO parameters available publicly
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Sauvat committed Jan 25, 2018
1 parent 1b0c680 commit 1e9f15e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.2.10
----
* Make PDO parameters available publicly

1.2.9
----
* Allow to specify the operator in where clause for Bean::searchBeans
Expand Down
10 changes: 5 additions & 5 deletions src/Database/SugarPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SugarPDO extends PDO
public function __construct(Application $sugarApp, $options = array())
{
$this->sugarApp = $sugarApp;
$params = $this->getPdoParams();
$params = self::getPdoParams($this->getApplication());
parent::__construct($params['dsn'], $params['username'], $params['password'], $options);
}

Expand All @@ -38,15 +38,15 @@ public function getApplication()
return $this->sugarApp;
}

protected function getPdoParams()
public static function getPdoParams(Application $sugarApp)
{
$sugar_config = $this->getApplication()->getSugarConfig();
$sugar_config = $sugarApp->getSugarConfig();
if (!array_key_exists('dbconfig', $sugar_config)
|| !is_array($sugar_config['dbconfig'])
) {
throw new SugarException('Configuration parameter "db_config" is not an array');
}
$dbconfig = $this->normalizeDbParams($sugar_config['dbconfig']);
$dbconfig = self::normalizeDbParams($sugar_config['dbconfig']);

$params = array(
'host' => $dbconfig['db_host_name'],
Expand All @@ -73,7 +73,7 @@ protected function getPdoParams()
*
* @throws SugarException if some required options are not present.
*/
public function normalizeDbParams($params)
public static function normalizeDbParams($params)
{
$defaults = array(
'db_password' => '',
Expand Down

0 comments on commit 1e9f15e

Please sign in to comment.