3 namespace Org\Mxchange\CoreFramework\Connector\Database;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Criteria\Criteria;
7 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
8 use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
9 use Org\Mxchange\CoreFramework\Database\FrameworkDatabase;
12 * An interface for middleware database classes
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
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.
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.
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/>.
33 interface DatabaseConnector extends FrameworkDatabase {
35 * Get an instance of this class (Singleton)
37 * @return $selfInstance An instance of this class
39 static function getSelfInstance ();
42 * Setter for database connection
44 * @param $login Login to database
45 * @param $pass Password (plain)
46 * @param $dbase Database to choose
47 * @param $host Hostname to use
50 function setConnectionData ($login, $pass, $dbase, $host='localhost');
53 * Getter for connection data
55 * @return $connectData Connection data stored with this clas
57 function getConnectionData ();
60 * Setter for the real database layer
61 * @param $dbLayer An instance of the real database layer
64 function setDatabaseLayer (DatabaseBackend $dbLayer);
67 * Getter for index key
69 * @return $indexKey Index key
71 function getIndexKey ();
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
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
81 function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
84 * Getter for last exception
86 * @return $exceptionInstance Last thrown exception
88 function getLastException ();
91 * 'Inserts' a data set instance into a local file database folder
93 * @param $dataSetInstance A storeable data set
96 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
99 * 'Updates' a data set instance with a database layer
101 * @param $dataSetInstance A storeable data set
104 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
107 * Getter for primary key column of specified table name
109 * @param $tableName Name of table we need the primary key column from
110 * @return $primaryKey Primary key column of requested table
112 function getPrimaryKeyOfTable ($tableName);
115 * Removes non-public data from given array.
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.
120 function removeNonPublicDataFromArray (array $data);
123 * Counts total rows of given table
125 * @param $tableName Table name
126 * @return $count Total rows of given table
128 function countTotalRows($tableName);