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