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