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