database
in
FanPress CM Database abstraction layer
Table of Contents
tableArticles | Article-Tabelle | 'articles' |
---|---|---|
tableAuthors | Benutzer-Tabelle | 'authors' |
tableCategories | Kategorie-Tabelle | 'categories' |
tableComments | Kommentar-Tabelle | 'comments' |
tableConfig | Config-Tabelle | 'config' |
tableCronjobs | Cronjob-Tabelle | 'cronjobs' |
tableFiles | Dateiindex-Tabelle | 'uploadfiles' |
tableIpAdresses | Tabeller gesperrter IP-Adressen | 'blockedip' |
tableModules | Modul-Tabelle | 'modules' |
tablePermissions | Tabelle für Berechtigungen | 'permissions' |
tableRoll | Benutzerrollen-Tabelle | 'userrolls' |
tableSessions | Sessions-Tabelle | 'sessions' |
tableShares | Share-Count-Tabelle | 'shares' |
tableSmileys | Smiley-Tabelle | 'smileys' |
tableTexts | Wordsperre-Tabelle | 'texts' |
tableRevisions | Tabelle für revisionen | 'revisions' |
viewSessionUserdata | View for session and user data | 'session_userdata' |
viewArticleCounts | View for article counts | 'articles_counts' |
DBTYPE_MYSQLMARIADB | Datenbank-TypKonstante MySQL | 'mysql' |
DBTYPE_POSTGRES | Datenbank-TypKonstante Postgres | 'pgsql' |
$supportedDBMS | Liste mit unterstützten Datenbanksystemen | |
$connection | Datenbank-Verbindung | PDO |
$driver | Datenbank-Treiber | sqlDriver |
$dbprefix | Tabellen-Prefix | string |
$dbtype | Datenbank-Typ | string |
$dbname | Database name | string |
$lastQueryString | letzter ausgeführter Datenbank-Querystring | string |
$lastQueryErrorCode | Common error code for last query | string |
$queryCount | Anzahl an Datenbank abgesetzte Queries | int |
$lastTable | Tabelle, in welcher zuletzt eine Aktion durchgeführt wurde | string |
$explain | SQL-Query via explain testen | bool |
$structCache | Table structure cache | array |
__construct() | Konstruktor | void |
__destruct() | Der Destruktor | mixed |
select() | Führt SELECT-Befehl auf DB aus | mixed |
selectFetch() | Executes select and fetch in one function | PDOStatement|array |
unionSelectFetch() | Executes UNION combined select and fetch | array |
insert() | Execute insert query | int |
update() | Führt UPDATE-Befehl auf DB aus | bool |
updateMultiple() | Führt mehrere UPDATE-Befehl auf DB mit einmal aus | bool |
delete() | Führt DELETE-Befehl auf DB aus | bool |
alter() | Ändert Tabellenstruktur via ALTER TABLE | bool |
count() | Zählt nach den angebenen Einstellungen | bool |
reverseBool() | Negiert den Wert des übergebenen Feldes | bool |
getMaxTableId() | Liefert höchten Wert einer Tabellen-ID | int |
drop() | Tabelle via DROP TABLE löschen | bool |
createIndex() | Index auf eine Spalte in der übergebenen Tabelle erzeugen | bool |
exec() | Executes a sql query | bool |
execSqlFile() | Führt SQL-Datei aus | bool |
execYaTdl() | Parst YaTDL-Datei und führt SQL-Statement aus | bool |
query() | Führt ein SQL Kommando aus und gibt Result-Set zurück | PDOStatement |
getStatementError() | Schreibt letzte Fehlermeldung des ausgefühtren Statements in DB-Log | bool |
fetch() | Returns result set from database query | mixed |
getLastInsertId() | Liefert ID des letzten Insert-Eintrags | string |
getLastQueryString() | Liefert zuletzt ausgeführten Query-String zurück | string |
getLastQueryErrorCode() | Returns common sql error code | string |
limitQuery() | Erzeugt LIMIT-SQL-String | string |
orderBy() | Erzeugt ORDER BY-SQL-String | string |
concatString() | Erzeugt CONCAT SQL-String | string |
implodeCols() | Erzeugt CONCAT_WS SQL-String | string |
inQuery() | Creates IN-Query for prepared statement | string |
dbLike() | Erzeugt LIKE-SQL-String | string |
optimize() | Erzeugt Query für Optimierungsvorgang auf Datenbank-Tabellen | bool |
getDbprefix() | Tabellen-Prefix zurückgeben | string |
getTablePrefixed() | Kompletten Tabellen-Name mit Prefix zurückgeben | string |
getDbtype() | Datenbank-Typ zurückgeben | string |
getQueryCount() | Gibt Anzahl an ausgeführt Datenbank-Queries zurück | int |
getYaTDLDataTypes() | Gibt Datentypen-Map zurück für YATDL | array |
getDbVersion() | Gibt Version des verbundenen Datenbank-Systems zurück | string |
checkDbVersion() | Prüft, ob aktuelle Version des DBMS >= der empfohlenen Version ist | string |
getRecommendVersion() | Gibt Version des verbundenen Datenbank-Systems zurück | string |
getTableStructure() | Returns database structure for certain table and/or column | array |
addTableCols() | Add columns to database table by definition in object of type @see \fpcm\model\system\yatdl | bool |
removeTableCols() | Removes columns to database table by definition in object of type @see \fpcm\model\system\yatdl | bool |
addTableIndices() | Add columns to database table by definition in object of type @see \fpcm\model\system\yatdl | bool |
createView() | Create view in database | bool |
createDbConfigFile() | Datei data/config/database.php erzeugen | bool |
dieError() | Error die | mixed |
getTableFiles() | Liefert YMl-Dateien aus Pfad zurück | array |
setExplain() | SQL-EXPLAIN de/aktivieren | mixed |
getPdoDns() | Returns PDO DNS string | string |
getPdoOptions() | Returns PDO options array | string |
getTableIndices() | Returns indices defined for the certain table and or column | array |
getLenghtTypes() | Return data types with length params | array |
replacePrefixVar() | Replaces {{dbpref}} variable in SQL query | bool |
Constants
tableArticles
Article-Tabelle
mixed
$tableArticles
= 'articles'
tableAuthors
Benutzer-Tabelle
mixed
$tableAuthors
= 'authors'
tableCategories
Kategorie-Tabelle
mixed
$tableCategories
= 'categories'
tableComments
Kommentar-Tabelle
mixed
$tableComments
= 'comments'
tableConfig
Config-Tabelle
mixed
$tableConfig
= 'config'
tableCronjobs
Cronjob-Tabelle
mixed
$tableCronjobs
= 'cronjobs'
tableFiles
Dateiindex-Tabelle
mixed
$tableFiles
= 'uploadfiles'
tableIpAdresses
Tabeller gesperrter IP-Adressen
mixed
$tableIpAdresses
= 'blockedip'
tableModules
Modul-Tabelle
mixed
$tableModules
= 'modules'
tablePermissions
Tabelle für Berechtigungen
mixed
$tablePermissions
= 'permissions'
tableRoll
Benutzerrollen-Tabelle
mixed
$tableRoll
= 'userrolls'
tableSessions
Sessions-Tabelle
mixed
$tableSessions
= 'sessions'
tableShares
Share-Count-Tabelle
mixed
$tableShares
= 'shares'
tableSmileys
Smiley-Tabelle
mixed
$tableSmileys
= 'smileys'
tableTexts
Wordsperre-Tabelle
mixed
$tableTexts
= 'texts'
tableRevisions
Tabelle für revisionen
mixed
$tableRevisions
= 'revisions'
viewSessionUserdata
View for session and user data
mixed
$viewSessionUserdata
= 'session_userdata'
viewArticleCounts
View for article counts
mixed
$viewArticleCounts
= 'articles_counts'
DBTYPE_MYSQLMARIADB
Datenbank-TypKonstante MySQL
mixed
$DBTYPE_MYSQLMARIADB
= 'mysql'
DBTYPE_POSTGRES
Datenbank-TypKonstante Postgres
mixed
$DBTYPE_POSTGRES
= 'pgsql'
Properties
$supportedDBMS
Liste mit unterstützten Datenbanksystemen
public
static mixed
$supportedDBMS
= array('mysql' => 'MySQL/ MariaDB', 'pgsql' => 'Postgres')
$connection
Datenbank-Verbindung
private
PDO
$connection
$driver
Datenbank-Treiber
private
sqlDriver
$driver
$dbprefix
Tabellen-Prefix
private
string
$dbprefix
$dbtype
Datenbank-Typ
private
string
$dbtype
$dbname
Database name
private
string
$dbname
$lastQueryString
letzter ausgeführter Datenbank-Querystring
private
string
$lastQueryString
= ''
$lastQueryErrorCode
Common error code for last query
private
string
$lastQueryErrorCode
= null
$queryCount
Anzahl an Datenbank abgesetzte Queries
private
int
$queryCount
= ""
$lastTable
Tabelle, in welcher zuletzt eine Aktion durchgeführt wurde
private
string
$lastTable
= ''
$explain
SQL-Query via explain testen
private
bool
$explain
= false
$structCache
Table structure cache
private
array
$structCache
= []
Methods
__construct()
Konstruktor
public
__construct(
[ $dbconfig :
array
= false ]
[, $dieOnError :
bool
= true ]
)
: void
Parameters
- $dbconfig : array = false
alternative Datenbank-Zugangsdaten, wenn false werden Daten aus FPCM-Config genutzt
- $dieOnError : bool = true
wenn Verbindung fehlschlägt, soll Ausführung vollständig abgebrochen werden
__destruct()
Der Destruktor
public
__destruct(
)
: mixed
Return values
mixedselect()
Führt SELECT-Befehl auf DB aus
public
select(
$table :
string
[, $item :
string
= '*' ]
[, $where :
string|null
= null ]
[, $params :
array
= [] ]
[, $distinct :
bool
= false ]
)
: mixed
Parameters
- $table : string
select table
- $item : string = '*'
select items
- $where : string|null = null
select condition
- $params : array = []
select condition params
- $distinct : bool = false
Distinct select
Return values
mixedselectFetch()
Executes select and fetch in one function
public
selectFetch(
$obj :
selectParams
)
: PDOStatement|array
Parameters
- $obj : selectParams
Return values
PDOStatement|arrayunionSelectFetch()
Executes UNION combined select and fetch
public
unionSelectFetch(
$selects :
array
[, $fetchStyle :
int
= \PDO::FETCH_OBJ ]
[, $returnResult :
bool
= false ]
)
: array
Parameters
- $selects : array
- $fetchStyle : int = \PDO::FETCH_OBJ
- $returnResult : bool = false
Tags
Return values
arrayinsert()
Execute insert query
public
insert(
$table :
string
, $values :
string
)
: int
Parameters
- $table : string
- $values : string
Return values
intupdate()
Führt UPDATE-Befehl auf DB aus
public
update(
$table :
string
, $fields :
array
[, $params :
array
= [] ]
[, $where :
string
= null ]
)
: bool
Parameters
- $table : string
- $fields : array
- $params : array = []
- $where : string = null
Return values
boolupdateMultiple()
Führt mehrere UPDATE-Befehl auf DB mit einmal aus
public
updateMultiple(
$table :
string
, $fields :
array
[, $params :
array
= [] ]
[, $where :
array
= [] ]
)
: bool
Parameters
- $table : string
- $fields : array
- $params : array = []
- $where : array = []
Tags
Return values
booldelete()
Führt DELETE-Befehl auf DB aus
public
delete(
$table :
string
[, $where :
string
= null ]
[, $params :
array
= [] ]
)
: bool
Parameters
- $table : string
- $where : string = null
- $params : array = []
Return values
boolalter()
Ändert Tabellenstruktur via ALTER TABLE
public
alter(
$table :
string
, $methode :
string
, $field :
string
[, $where :
string
= "" ]
[, $checkExists :
bool
= true ]
)
: bool
Parameters
- $table : string
- $methode : string
- $field : string
- $where : string = ""
- $checkExists : bool = true
Prüfung durchführen, ob Feld existiert
Return values
boolcount()
Zählt nach den angebenen Einstellungen
public
count(
$table :
string
[, $countitem :
string
= '*' ]
[, $where :
string
= null ]
[, $params :
array
= [] ]
)
: bool
Parameters
- $table : string
In welcher Tabelle soll gezählt werden
- $countitem : string = '*'
Welche Spalte soll gezählt werden
- $where : string = null
Nach welchen Filterkriterien soll gezählt werden
- $params : array = []
Return values
boolreverseBool()
Negiert den Wert des übergebenen Feldes
public
reverseBool(
$table :
string|array
, $field :
string
, $where :
string
)
: bool
Parameters
- $table : string|array
- $field : string
- $where : string
Return values
boolgetMaxTableId()
Liefert höchten Wert einer Tabellen-ID
public
getMaxTableId(
$table :
string
)
: int
Parameters
- $table : string
Tabellen-Name
Return values
intdrop()
Tabelle via DROP TABLE löschen
public
drop(
$table :
string
)
: bool
Parameters
- $table : string
Return values
boolcreateIndex()
Index auf eine Spalte in der übergebenen Tabelle erzeugen
public
createIndex(
$table :
string
, $indexName :
string
, $field :
string
[, $isUnique :
bool
= false ]
)
: bool
Parameters
- $table : string
- $indexName : string
- $field : string
- $isUnique : bool = false
Tags
Return values
boolexec()
Executes a sql query
public
exec(
$command :
string
[, $bindParams :
array
= [] ]
)
: bool
Parameters
- $command : string
- $bindParams : array = []
Return values
boolexecSqlFile()
Führt SQL-Datei aus
public
execSqlFile(
$path :
string
)
: bool
Parameters
- $path : string
Tags
Return values
boolexecYaTdl()
Parst YaTDL-Datei und führt SQL-Statement aus
public
execYaTdl(
$path :
string
)
: bool
Parameters
- $path : string
Tags
Return values
boolquery()
Führt ein SQL Kommando aus und gibt Result-Set zurück
public
query(
$command :
string
[, $bindParams :
array
= [] ]
)
: PDOStatement
Parameters
- $command : string
SQL String
- $bindParams : array = []
Paramater, welche gebunden werden sollen
Return values
PDOStatementgetStatementError()
Schreibt letzte Fehlermeldung des ausgefühtren Statements in DB-Log
public
getStatementError(
&$statement :
PDOStatement
)
: bool
Parameters
- $statement : PDOStatement
Return values
boolfetch()
Returns result set from database query
public
fetch(
$result :
PDOStatement
[, $getAll :
bool
= false ]
[, $style :
int
= \PDO::FETCH_OBJ ]
)
: mixed
Parameters
- $result : PDOStatement
- $getAll : bool = false
- $style : int = \PDO::FETCH_OBJ
Return values
mixedgetLastInsertId()
Liefert ID des letzten Insert-Eintrags
public
getLastInsertId(
)
: string
Return values
stringgetLastQueryString()
Liefert zuletzt ausgeführten Query-String zurück
public
getLastQueryString(
)
: string
Return values
stringgetLastQueryErrorCode()
Returns common sql error code
public
getLastQueryErrorCode(
)
: string
Tags
Return values
stringlimitQuery()
Erzeugt LIMIT-SQL-String
public
limitQuery(
$offset :
int
, $limit :
int
)
: string
Parameters
- $offset : int
- $limit : int
Return values
stringorderBy()
Erzeugt ORDER BY-SQL-String
public
orderBy(
$conditions :
array
)
: string
Parameters
- $conditions : array
Return values
stringconcatString()
Erzeugt CONCAT SQL-String
public
concatString(
$fields :
array
)
: string
Parameters
- $fields : array
Tags
Return values
stringimplodeCols()
Erzeugt CONCAT_WS SQL-String
public
implodeCols(
$delim :
string
, $fields :
array
)
: string
Parameters
- $delim : string
- $fields : array
Tags
Return values
stringinQuery()
Creates IN-Query for prepared statement
public
inQuery(
$field :
string
, $values :
array
[, $not :
bool
= false ]
)
: string
Parameters
- $field : string
- $values : array
- $not : bool = false
Tags
Return values
stringdbLike()
Erzeugt LIKE-SQL-String
public
dbLike(
)
: string
Tags
Return values
stringoptimize()
Erzeugt Query für Optimierungsvorgang auf Datenbank-Tabellen
public
optimize(
$table :
string
)
: bool
Parameters
- $table : string
Name der Tabelle
Tags
Return values
boolgetDbprefix()
Tabellen-Prefix zurückgeben
public
getDbprefix(
)
: string
Return values
stringgetTablePrefixed()
Kompletten Tabellen-Name mit Prefix zurückgeben
public
getTablePrefixed(
$table :
string
)
: string
Parameters
- $table : string
Tags
Return values
stringgetDbtype()
Datenbank-Typ zurückgeben
public
getDbtype(
)
: string
Tags
Return values
stringgetQueryCount()
Gibt Anzahl an ausgeführt Datenbank-Queries zurück
public
getQueryCount(
)
: int
Tags
Return values
intgetYaTDLDataTypes()
Gibt Datentypen-Map zurück für YATDL
public
getYaTDLDataTypes(
)
: array
Tags
Return values
arraygetDbVersion()
Gibt Version des verbundenen Datenbank-Systems zurück
public
getDbVersion(
)
: string
Tags
Return values
stringcheckDbVersion()
Prüft, ob aktuelle Version des DBMS >= der empfohlenen Version ist
public
checkDbVersion(
)
: string
Tags
Return values
stringgetRecommendVersion()
Gibt Version des verbundenen Datenbank-Systems zurück
public
getRecommendVersion(
)
: string
Tags
Return values
stringgetTableStructure()
Returns database structure for certain table and/or column
public
getTableStructure(
$table :
string
[, $field :
string
= false ]
[, $cache :
string
= true ]
)
: array
Parameters
- $table : string
- $field : string = false
- $cache : string = true
Tags
Return values
arrayaddTableCols()
Add columns to database table by definition in object of type @see \fpcm\model\system\yatdl
public
addTableCols(
$yatdl :
yatdl
)
: bool
Parameters
- $yatdl : yatdl
Return values
boolremoveTableCols()
Removes columns to database table by definition in object of type @see \fpcm\model\system\yatdl
public
removeTableCols(
$yatdl :
yatdl
)
: bool
Parameters
- $yatdl : yatdl
Return values
booladdTableIndices()
Add columns to database table by definition in object of type @see \fpcm\model\system\yatdl
public
addTableIndices(
$yatdl :
yatdl
)
: bool
Parameters
- $yatdl : yatdl
Tags
Return values
boolcreateView()
Create view in database
public
createView(
$viewName :
string
, $queryString :
string
)
: bool
Parameters
- $viewName : string
- $queryString : string
Tags
Return values
boolcreateDbConfigFile()
Datei data/config/database.php erzeugen
public
createDbConfigFile(
$data :
array
)
: bool
Parameters
- $data : array
Tags
Return values
booldieError()
Error die
private
dieError(
)
: mixed
Return values
mixedgetTableFiles()
Liefert YMl-Dateien aus Pfad zurück
public
static getTableFiles(
[ $path :
string
= false ]
)
: array
Parameters
- $path : string = false
Tags
Return values
arraysetExplain()
SQL-EXPLAIN de/aktivieren
public
setExplain(
$explain :
bool
)
: mixed
Parameters
- $explain : bool
Tags
Return values
mixedgetPdoDns()
Returns PDO DNS string
public
getPdoDns(
)
: string
Return values
stringgetPdoOptions()
Returns PDO options array
public
getPdoOptions(
)
: string
Return values
stringgetTableIndices()
Returns indices defined for the certain table and or column
public
getTableIndices(
$table :
string
[, $field :
string
= false ]
[, $cache :
bool
= true ]
)
: array
Parameters
- $table : string
- $field : string = false
- $cache : bool = true
Tags
Return values
arraygetLenghtTypes()
Return data types with length params
private
getLenghtTypes(
)
: array
Return values
arrayreplacePrefixVar()
Replaces {{dbpref}} variable in SQL query
private
replacePrefixVar(
&$sql :
string
)
: bool
Parameters
- $sql : string