3 namespace CoreFramework\Connector\Database;
5 // Import framework stuff
6 use CoreFramework\Criteria\Criteria;
9 * An interface for middleware database classes
11 * @author Roland Haeder <webmaster@shipsimu.org>
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
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.
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.
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/>.
30 interface DatabaseConnector extends FrameworkDatabase {
32 * Get an instance of this class (Singleton)
34 * @return $selfInstance An instance of this class
36 static function getSelfInstance ();
39 * Setter for database connection
41 * @param $login Login to database
42 * @param $pass Password (plain)
43 * @param $dbase Database to choose
44 * @param $host Hostname to use
47 function setConnectionData ($login, $pass, $dbase, $host='localhost');
50 * Getter for connection data
52 * @return $connectData Connection data stored with this clas
54 function getConnectionData ();
57 * Setter for the real database layer
58 * @param $dbLayer An instance of the real database layer
61 function setDatabaseLayer (DatabaseBackend $dbLayer);
64 * Getter for index key
66 * @return $indexKey Index key
68 function getIndexKey ();
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
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
78 function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
81 * Getter for last exception
83 * @return $exceptionInstance Last thrown exception
85 function getLastException ();
88 * 'Inserts' a data set instance into a local file database folder
90 * @param $dataSetInstance A storeable data set
93 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
96 * 'Updates' a data set instance with a database layer
98 * @param $dataSetInstance A storeable data set
101 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
104 * Getter for primary key column of specified table name
106 * @param $tableName Name of table we need the primary key column from
107 * @return $primaryKey Primary key column of requested table
109 function getPrimaryKeyOfTable ($tableName);
112 * Removes non-public data from given array.
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.
117 function removeNonPublicDataFromArray (array $data);
120 * Counts total rows of given table
122 * @param $tableName Table name
123 * @return $count Total rows of given table
125 function countTotalRows($tableName);