File modules/database/DbVersion.class.php
Last commit: Thu Feb 16 01:04:38 2023 +0100 Jan Dankert New: Tags for base objects.
1 <?php 2 3 4 namespace database; 5 6 7 abstract class DbVersion 8 { 9 const TYPE_MYSQL = 1; 10 const TYPE_POSTGRES = 2; 11 const TYPE_SQLITE = 3; 12 const TYPE_ORACLE = 4; // Attention: ORACLE is NOT really supported. 13 14 private $db; 15 private $tablePrefix; 16 private $tableSuffix; 17 18 /** 19 * Datenbank-RDBMS-Typ 20 */ 21 private $dbmsType; 22 23 /** 24 * DbVersion constructor. 25 * @param Database $db 26 */ 27 public function __construct(Database $db) 28 { 29 $this->db = $db; 30 31 switch ($db->conf['type']) { 32 case 'pdo': 33 if ( $db->conf['dsn'] ) { 34 $dsnParts = explode(':', $db->conf['dsn']); 35 $driver = $dsnParts[0]; 36 }else { 37 $driver = $db->conf['driver']; 38 } 39 switch ($driver) { 40 case 'mysql': 41 $this->dbmsType = DbVersion::TYPE_MYSQL; 42 break; 43 case 'pgsql': 44 $this->dbmsType = DbVersion::TYPE_POSTGRES; 45 break; 46 case 'sqlite': 47 $this->dbmsType = DbVersion::TYPE_SQLITE; 48 break; 49 default: 50 throw new \LogicException('Unknown PDO driver: ' . $driver); 51 } 52 break; 53 default: 54 // for now we are only supporting PDO. 55 throw new \LogicException('Unknown DBMS type: ' . $db->conf['type']); 56 } 57 58 $this->tablePrefix = $db->conf['prefix']; 59 $this->tableSuffix = $db->conf['suffix']; 60 } 61 62 // Muss überschrieben werden! 63 abstract function update(); 64 65 66 /** 67 * @param $tableName String table name 68 * @return Table 69 */ 70 public function table( $tableName ) { 71 return new Table( $this->getDb(),$this->dbmsType, $tableName ); 72 } 73 74 75 /** 76 * @return Database 77 */ 78 function getDb() 79 { 80 return $this->db; 81 } 82 83 }
Downloadmodules/database/DbVersion.class.php
History Thu, 16 Feb 2023 01:04:38 +0100 Jan Dankert New: Tags for base objects. Sat, 31 Oct 2020 00:43:29 +0100 Jan Dankert New: Support for OpenId Connect; Removed: Support for LDAP. Fri, 23 Oct 2020 11:28:46 +0200 Jan Dankert Fix: Getting the PDO driver from the DSN. Tue, 29 Sep 2020 22:17:11 +0200 Jan Dankert Refactoring: Do not use global constants. Fri, 25 Sep 2020 01:00:58 +0200 Jan Dankert Refactoring: More OO in the database updater :) Sun, 23 Feb 2020 00:16:20 +0100 Jan Dankert Refactoring: Namespacing for module 'database'. Sat, 22 Feb 2020 23:58:02 +0100 Jan Dankert Refactoring: Namespacing for module 'util'. Fri, 3 Aug 2018 23:30:19 +0200 Jan Dankert Neue Datenbankspalten für Textfilterung, Veröffentlichungsdatum, Ordnersortierung. Feature 0000003 0000004 0000005 Wed, 20 Dec 2017 23:02:40 +0100 Jan Dankert Das Projekt erhält eine neue Spalte 'flags', in der alle möglichen Einstellungen als Bitmaske hinterlegt werden können. Außerdem Refactoring der DBUpdate-Schnittstelle, möglichst häufig Konstanten verwenden. Thu, 7 Dec 2017 00:39:30 +0100 Jan Dankert Type-Hints ergänzt, damit die IDE besser unterstützen kann. Tue, 5 Dec 2017 23:56:04 +0100 Jan Dankert Datenbank-Klassen auf Namespace umgestellt. Sun, 3 Dec 2017 03:11:38 +0100 Jan Dankert Refactoring: Datenbank-Funktionen in ein eigenes "Modul" ausgelagert.