3 * An interface for middleware database classes
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
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.
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.
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/>.
24 interface DatabaseConnector extends FrameworkDatabase {
26 * Get an instance of this class (Singleton)
28 * @return $selfInstance An instance of this class
30 static function getSelfInstance ();
33 * Setter for database connection
35 * @param $login Login to database
36 * @param $pass Password (plain)
37 * @param $dbase Database to choose
38 * @param $host Hostname to use
41 function setConnectionData ($login, $pass, $dbase, $host='localhost');
44 * Getter for connection data
46 * @return $connectData Connection data stored with this clas
48 function getConnectionData ();
51 * Setter for the real database layer
52 * @param $dbLayer An instance of the real database layer
55 function setDatabaseLayer (DatabaseBackend $dbLayer);
58 * Getter for index key
60 * @return $indexKey Index key
62 function getIndexKey ();
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
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
72 function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
75 * Getter for last exception
77 * @return $exceptionInstance Last thrown exception
79 function getLastException ();
82 * 'Inserts' a data set instance into a local file database folder
84 * @param $dataSetInstance A storeable data set
87 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
90 * 'Updates' a data set instance with a database layer
92 * @param $dataSetInstance A storeable data set
95 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
98 * Getter for primary key column of specified table name
100 * @param $tableName Name of table we need the primary key column from
101 * @return $primaryKey Primary key column of requested table
103 function getPrimaryKeyOfTable ($tableName);
106 * Removes non-public data from given array.
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.
111 function removeNonPublicDataFromArray (array $data);