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\FrameworkDatabase;
11 * An interface for middleware database classes
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
16 * @license GNU GPL 3.0 or any newer version
17 * @link http://www.shipsimu.org
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 interface DatabaseConnector extends FrameworkDatabase {
34 * Get an instance of this class (Singleton)
36 * @return $selfInstance An instance of this class
38 static function getSelfInstance ();
41 * Setter for database connection
43 * @param $login Login to database
44 * @param $pass Password (plain)
45 * @param $dbase Database to choose
46 * @param $host Hostname to use
49 function setConnectionData (string $login, string $pass, string $dbase, string $host = 'localhost');
52 * Getter for connection data
54 * @return $connectData Connection data stored with this clas
56 function getConnectionData ();
59 * Getter for index key
61 * @return $indexKey Index key
63 function getIndexKey ();
66 * Runs a 'select' statement on the database layer with given table name
67 * and criteria. If this doesn't fail the result will be returned
69 * @param $tableName Name of the 'table' we shall query
70 * @param $criteriaInstance An instance of a Criteria class
71 * @return $result The result as an array
73 function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance);
76 * Getter for last exception
78 * @return $exceptionInstance Last thrown exception
80 function getLastException ();
83 * 'Inserts' a data set instance into a local file database folder
85 * @param $dataSetInstance A storeable data set
88 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
91 * 'Updates' a data set instance with a database layer
93 * @param $dataSetInstance A storeable data set
96 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
99 * Getter for primary key column of specified table name
101 * @param $tableName Name of table we need the primary key column from
102 * @return $primaryKey Primary key column of requested table
104 function getPrimaryKeyOfTable (string $tableName);
107 * Removes non-public data from given array.
109 * @param $data An array with possible non-public data that needs to be removed.
110 * @return $data A cleaned up array with only public data.
112 function removeNonPublicDataFromArray (array $data);
115 * Counts total rows of given table
117 * @param $tableName Table name
118 * @return $count Total rows of given table
120 function countTotalRows (string $tableName);