[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 05/39: Code : add connection by DSN
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 05/39: Code : add connection by DSN |
Date: |
Sat, 11 Jul 2020 13:20:36 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 741a1c1417b4ba5443af24e300d09b0b3173651f
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Mon May 11 00:10:23 2020 +0200
Code : add connection by DSN
---
include/lib/database_core.class.php | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/include/lib/database_core.class.php
b/include/lib/database_core.class.php
index 098b7d6..4e4bac2 100644
--- a/include/lib/database_core.class.php
+++ b/include/lib/database_core.class.php
@@ -77,6 +77,42 @@ class DatabaseCore
$this->is_open = TRUE;
}
+ /**
+ * Connect by DSN : description of database connection like
+ * return a Database_Core object
+ * @code
+ * port=6002 host=x.x.x.x dbname=dbname user=admin password=www
+ * @endcode
+ *
+ * @param string $p_dsn describing the connection
+ *
+ */
+ function connect_dsn($p_dsn)
+ {
+ $this->db =pg_connect($p_dsn);
+
+ if ( $this->db == false )
+ {
+ if (DEBUG) {
+ echo '<h2 class="error">Impossible de se connecter à
postgreSql !</h2>';
+ echo '<p>';
+ echo "Vos paramètres sont incorrectes : <br>";
+ echo "<br>";
+ echo "base de donnée : $p_dsn<br>";
+ echo '</p>';
+
+ exit ("Connection impossible : vérifiez vos
paramètres de base
+ de données");
+ } else {
+ echo '<h2 class="error">' . _('Erreur de connexion !') .
'</h2>';
+ $this->is_open = false;
+ throw new Exception(_('Erreur Connexion'));
+ }
+
+ }
+ $this->is_open=TRUE;
+ return $this;
+ }
public function verify()
{
- [Noalyss-commit] [noalyss] branch master updated (aa78d59 -> 3450d5f), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 01/39: Pierre-François P. Ajout des parenthèses dans le calcul des champs numériques, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 05/39: Code : add connection by DSN,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 07/39: Remove DB connect with DSN, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 04/39: Fix bug in recover password Include sendmail.class.php fix bug sending email with file (compatibility PHP7), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 10/39: Task #1532 : detail payment, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 11/39: #1583: [Cosmétique] Liste de catégories de fiches, espace avant les (), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 08/39: #1798 French calendar, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 09/39: Compatility PHP7.4, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 02/39: Bug Database:lo_unlink unknown variable, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 06/39: Compatibility postgresql 12, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 03/39: Fix problem with redirect, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 12/39: CSS : new background-selected for a row in table, Dany De Bontridder, 2020/07/11