3 namespace Org\Mxchange\CoreFramework\Database\Backend;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
7 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
8 use Org\Mxchange\CoreFramework\Database\FrameworkDatabase;
11 * An interface for front-end database classes. The classes should prepare the
12 * objects for saving in the database. So for server-bases database classes SQL
13 * queries shall be generated and send to the backend classes. In case of local
14 * file databases the object shall be serialized and (maybe) transparently
15 * compressed before they got saved to a local file.
17 * @author Roland Haeder <webmaster@shipsimu.org>
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.shipsimu.org
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 interface DatabaseBackend extends FrameworkDatabase {
38 * Getter for last read file
40 * @return $lastFile The last read file's name with full path
42 function getLastFile ();
45 * Getter for last read file's content as an array
47 * @return $lastContent The array with elements 'header' and 'data'.
49 function getLastContents ();
52 * Getter for file extension
54 * @return $fileExtension The array with elements 'header' and 'data'.
56 function getFileExtension ();
59 * Getter for index key
61 * @return $indexKey Index key
63 function getIndexKey ();
66 * Makes sure that the database connection is alive
69 * @todo Do some checks on the database directory and files here
71 function connectToDatabase ();
74 * Starts a SELECT query on the database by given return type, table name
77 * @param $tableName Name of the database table
78 * @param $searchInstance Local search criteria class
79 * @return $resultData Result data of the query
80 * @throws UnsupportedCriteriaException If the criteria is unsupported
81 * @throws SqlException If an 'SQL error' occurs
83 function querySelect (string $tableName, LocalSearchCriteria $searchInstance);
86 * "Inserts" a data set instance into a local file database folder
88 * @param $dataSetInstance A storeable data set
90 * @throws SqlException If an SQL error occurs
92 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
95 * "Updates" a data set instance with a database layer
97 * @param $dataSetInstance A storeable data set
99 * @throws SqlException If an SQL error occurs
101 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
104 * Getter for primary key of specified table or if not found null will be
105 * returned. This must be database-specific.
107 * @param $tableName Name of the table we need the primary key from
108 * @return $primaryKey Primary key column of the given table
110 function getPrimaryKeyOfTable (string $tableName);
113 * Removes non-data from given array.
115 * @param $data An array with possible non-data that needs to be removed.
116 * @return $data A cleaned up array with only data.
117 * @todo Add more generic non-data for removal
119 function removeNonPublicDataFromArray (array $data);
122 * Counts total rows of given table
124 * @param $tableName Table name
125 * @return $count Total rows of given table
127 function countTotalRows(string $tableName);