]> git.mxchange.org Git - core.git/blob - framework/main/interfaces/database/middleware/class_DatabaseConnector.php
ee45bb0add2da45a922e7b3416be1b8cb086c75e
[core.git] / framework / main / interfaces / database / middleware / class_DatabaseConnector.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Connector\Database;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Criteria\Criteria;
7 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
8 use Org\Mxchange\CoreFramework\Database\FrameworkDatabase;
9
10 /**
11  * An interface for middleware database classes
12  *
13  * @author              Roland Haeder <webmaster@shipsimu.org>
14  * @version             0.0.0
15  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
16  * @license             GNU GPL 3.0 or any newer version
17  * @link                http://www.shipsimu.org
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  */
32 interface DatabaseConnector extends FrameworkDatabase {
33         /**
34          * Get an instance of this class (Singleton)
35          *
36          * @return      $selfInstance   An instance of this class
37          */
38         static function getSelfInstance ();
39
40         /**
41          * Setter for database connection
42          *
43          * @param       $login  Login to database
44          * @param       $pass   Password (plain)
45          * @param       $dbase  Database to choose
46          * @param       $host   Hostname to use
47          * @return      void
48          */
49         function setConnectionData (string $login, string $pass, string $dbase, string $host = 'localhost');
50
51         /**
52          * Getter for connection data
53          *
54          * @return      $connectData    Connection data stored with this clas
55          */
56         function getConnectionData ();
57
58         /**
59          * Getter for index key
60          *
61          * @return      $indexKey       Index key
62          */
63         function getIndexKey ();
64
65         /**
66          * Runs a 'select' statement on the database layer with given table name
67          * and criteria. If this doesn't fail the result will be returned
68          *
69          * @param       $tableName                      Name of the 'table' we shall query
70          * @param       $criteriaInstance       An instance of a Criteria class
71          * @return      $result                         The result as an array
72          */
73         function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance);
74
75         /**
76          * Getter for last exception
77          *
78          * @return      $exceptionInstance      Last thrown exception
79          */
80         function getLastException ();
81
82         /**
83          * 'Inserts' a data set instance into a local file database folder
84          *
85          * @param       $dataSetInstance        A storeable data set
86          * @return      void
87          */
88         function queryInsertDataSet (StoreableCriteria $dataSetInstance);
89
90         /**
91          * 'Updates' a data set instance with a database layer
92          *
93          * @param       $dataSetInstance        A storeable data set
94          * @return      void
95          */
96         function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
97
98         /**
99          * Getter for primary key column of specified table name
100          *
101          * @param       $tableName              Name of table we need the primary key column from
102          * @return      $primaryKey             Primary key column of requested table
103          */
104         function getPrimaryKeyOfTable (string $tableName);
105
106         /**
107          * Removes non-public data from given array.
108          *
109          * @param       $data   An array with possible non-public data that needs to be removed.
110          * @return      $data   A cleaned up array with only public data.
111          */
112         function removeNonPublicDataFromArray (array $data);
113
114         /**
115          * Counts total rows of given table
116          *
117          * @param       $tableName      Table name
118          * @return      $count          Total rows of given table
119          */
120         function countTotalRows (string $tableName);
121
122 }