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 <<<<<<< HEAD:framework/main/interfaces/database/middleware/class_DatabaseConnector.php
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
20 >>>>>>> Some updates::inc/main/interfaces/database/middleware/class_DatabaseConnector.php
21 * @license GNU GPL 3.0 or any newer version
22 * @link http://www.shipsimu.org
24 * This program is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program. If not, see <http://www.gnu.org/licenses/>.
37 interface DatabaseConnector extends FrameworkDatabase {
39 * Get an instance of this class (Singleton)
41 * @return $selfInstance An instance of this class
43 static function getSelfInstance ();
46 * Setter for database connection
48 * @param $login Login to database
49 * @param $pass Password (plain)
50 * @param $dbase Database to choose
51 * @param $host Hostname to use
54 function setConnectionData ($login, $pass, $dbase, $host='localhost');
57 * Getter for connection data
59 * @return $connectData Connection data stored with this clas
61 function getConnectionData ();
64 * Setter for the real database layer
65 * @param $dbLayer An instance of the real database layer
68 function setDatabaseLayer (DatabaseBackend $dbLayer);
71 * Getter for index key
73 * @return $indexKey Index key
75 function getIndexKey ();
78 * Runs a 'select' statement on the database layer with given table name
79 * and criteria. If this doesn't fail the result will be returned
81 * @param $tableName Name of the 'table' we shall query
82 * @param $criteriaInstance An instance of a Criteria class
83 * @return $result The result as an array
85 function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
88 * Getter for last exception
90 * @return $exceptionInstance Last thrown exception
92 function getLastException ();
95 * 'Inserts' a data set instance into a local file database folder
97 * @param $dataSetInstance A storeable data set
100 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
103 * 'Updates' a data set instance with a database layer
105 * @param $dataSetInstance A storeable data set
108 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
111 * Getter for primary key column of specified table name
113 * @param $tableName Name of table we need the primary key column from
114 * @return $primaryKey Primary key column of requested table
116 function getPrimaryKeyOfTable ($tableName);
119 * Removes non-public data from given array.
121 * @param $data An array with possible non-public data that needs to be removed.
122 * @return $data A cleaned up array with only public data.
124 function removeNonPublicDataFromArray (array $data);
127 * Counts total rows of given table
129 * @param $tableName Table name
130 * @return $count Total rows of given table
132 function countTotalRows($tableName);