--- a/classes/bfw/database/Database.php
+++ b/classes/bfw/database/Database.php
@@ -20,10 +20,16 @@
*/
private $pdo;
- private function __construct() {
+ /**
+ * Database constructor.
+ * @param null|array $cfg
+ */
+ private function __construct($cfg = null) {
$this->logger = Logger::getLogger(__CLASS__);
- $cfg = Configuration::getDataSourceProperties();
+ if ($cfg == null) {
+ $cfg = Configuration::getDataSourceProperties();
+ }
$dsn = $cfg['dsn'];
$config = $cfg['config'];
@@ -43,11 +49,12 @@
* Definition des States: Ein Abfrageergebnis stellt solange den State des SP da, bis eine neue Abfrage
* einen neuen State erzeugt.
*
+ * @param null|array $cfg
* @return Database
*/
- public static function getInstance() {
+ public static function getInstance($cfg = null) {
if (self::$handle == null) {
- self::$handle = new Database();
+ self::$handle = new Database($cfg);
}
return self::$handle;
@@ -321,6 +328,14 @@
}
/**
+ * @param $sql
+ * @return int
+ */
+ public function execute($sql) {
+ return $this->pdo->exec($sql);
+ }
+
+ /**
* @param $table
* @param $array
* @return int