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