[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 08/16: Improve Code: Database : add __toStrin
From: |
dwm |
Subject: |
[Noalyss-commit] [noalyss] 08/16: Improve Code: Database : add __toString |
Date: |
Tue, 27 May 2025 09:26:08 -0400 (EDT) |
sparkyx pushed a commit to branch unstable
in repository noalyss.
commit 001677eb7230c24cc8ac5f3ee2a80902e2c7082a
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Mon May 19 23:01:31 2025 +0200
Improve Code: Database : add __toString
---
include/class/database.class.php | 13 +++++++++++--
include/lib/database_core.class.php | 33 ++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/include/class/database.class.php b/include/class/database.class.php
index 22865788a..38a8e0daf 100644
--- a/include/class/database.class.php
+++ b/include/class/database.class.php
@@ -69,9 +69,18 @@ class Database extends DatabaseCore
$this->exec_sql('set search_path to
public,comptaproc,pg_catalog;');
}
$this->exec_sql('set DateStyle to ISO, MDY;');
-
+ $this->ret=true;
+ $this->is_open=true;
}
-
+ function __toString(): string {
+ return "DatabaseCore[db=" . var_export($this->db,true)
+ . ", ret=" .var_export( $this->ret,true)
+ . ", is_open=" . $this->is_open
+ . ", sql=" . $this->sql
+ . ", array=" . var_export($this->array,true)
+ . ",dbname = ".$this->get_dbname()
+ . "]";
+}
/***
* \brief Save a "piece justificative" , the name must be pj
*
diff --git a/include/lib/database_core.class.php
b/include/lib/database_core.class.php
index 1a9ba6efc..04602f3ff 100644
--- a/include/lib/database_core.class.php
+++ b/include/lib/database_core.class.php
@@ -37,12 +37,17 @@ class DatabaseCore
protected $db;
/**< database connection */
- private $ret;
+ protected $ret;
/**< return value */
- private $is_open; /*!< true is connected */
+ protected $is_open; /*!< true is connected */
public $sql; //!< last SQL stmt executed
public $array;
- /*** Connect to a database return an connx to db or false if it fails
+ protected $dbname; ///!< $dbname (string) Database name
+ protected $dbport;///!< $dbport (int) Database port
+ protected $dbhost;///!< $dbhost(string) Database host
+ protected $dbuser;///!< $dbuser(string) Database user
+ /***
+ * @brief Connect to a database return an connx to db or false if it fails
*
* @param string $p_user Username
* @param type $p_password User's password
@@ -74,13 +79,31 @@ class DatabaseCore
throw new Exception(_('Erreur Connexion'));
}
}
-
+ $this->dbport=$p_port;
+ $this->dbname=$p_dbname;
+ $this->dbhost=$p_host;
+ $this->dbuser=$p_user;
$this->is_open = TRUE;
$this->sql="";
}
+ public function get_dbname() {
+ return $this->dbname;
+ }
- /**
+ public function get_dbport() {
+ return $this->dbport;
+ }
+
+ public function get_dbhost() {
+ return $this->dbhost;
+ }
+
+ public function get_dbuser() {
+ return $this->dbuser;
+ }
+
+ /**
* return the name of the current database
* @return false|string
*/
- [Noalyss-commit] [noalyss] branch unstable updated (a21554139 -> 34489f687), dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 03/16: Cosmetic width menu, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 10/16: Data_SQL and Table_Data_SQL add virtual column, to allow transformation of columns in SQL, faster than transforming in PHP afterward, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 04/16: FIX bug due changes Data_SQL, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 02/16: FONT MONSERRAT ROBOTO Title and menu, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 05/16: FREC : checkbox, checked by range, hidden elements must not be checked, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 08/16: Improve Code: Database : add __toString,
dwm <=
- [Noalyss-commit] [noalyss] 14/16: Add column timestamp for table TOOL_UOS, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 01/16: Code Improve : Data_SQL, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 06/16: FIX bug due changes Data_SQL, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 07/16: Detail Operation for small screen, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 09/16: Code Improve : Single_Record, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 12/16: Data_SQL if we use $this->sql , then must be set SQL, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 13/16: Data_SQL if column doesn't exist, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 15/16: Fix bug : wrong function name, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 11/16: CSS : cosmetic : font in a variable + outline input text in orange, dwm, 2025/05/27
- [Noalyss-commit] [noalyss] 16/16: PHP8.3 comptability, dynamic members, dwm, 2025/05/27