3 namespace CoreFramework\Connector\Database;
6 * An interface for middleware database classes
8 * @author Roland Haeder <webmaster@shipsimu.org>
10 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
11 * @license GNU GPL 3.0 or any newer version
12 * @link http://www.shipsimu.org
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 interface DatabaseConnector extends FrameworkDatabase {
29 * Get an instance of this class (Singleton)
31 * @return $selfInstance An instance of this class
33 static function getSelfInstance ();
36 * Setter for database connection
38 * @param $login Login to database
39 * @param $pass Password (plain)
40 * @param $dbase Database to choose
41 * @param $host Hostname to use
44 function setConnectionData ($login, $pass, $dbase, $host='localhost');
47 * Getter for connection data
49 * @return $connectData Connection data stored with this clas
51 function getConnectionData ();
54 * Setter for the real database layer
55 * @param $dbLayer An instance of the real database layer
58 function setDatabaseLayer (DatabaseBackend $dbLayer);
61 * Getter for index key
63 * @return $indexKey Index key
65 function getIndexKey ();
68 * Runs a 'select' statement on the database layer with given table name
69 * and criteria. If this doesn't fail the result will be returned
71 * @param $tableName Name of the 'table' we shall query
72 * @param $criteriaInstance An instance of a Criteria class
73 * @return $result The result as an array
75 function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
78 * Getter for last exception
80 * @return $exceptionInstance Last thrown exception
82 function getLastException ();
85 * 'Inserts' a data set instance into a local file database folder
87 * @param $dataSetInstance A storeable data set
90 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
93 * 'Updates' a data set instance with a database layer
95 * @param $dataSetInstance A storeable data set
98 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
101 * Getter for primary key column of specified table name
103 * @param $tableName Name of table we need the primary key column from
104 * @return $primaryKey Primary key column of requested table
106 function getPrimaryKeyOfTable ($tableName);
109 * Removes non-public data from given array.
111 * @param $data An array with possible non-public data that needs to be removed.
112 * @return $data A cleaned up array with only public data.
114 function removeNonPublicDataFromArray (array $data);
117 * Counts total rows of given table
119 * @param $tableName Table name
120 * @return $count Total rows of given table
122 function countTotalRows($tableName);