3 namespace CoreFramework\Database\Backend;
6 * An interface for front-end database classes. The classes should prepare the
7 * objects for saving in the database. So for server-bases database classes SQL
8 * queries shall be generated and send to the backend classes. In case of local
9 * file databases the object shall be serialized and (maybe) transparently
10 * compressed before they got saved to a local file.
12 * @author Roland Haeder <webmaster@shipsimu.org>
14 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
15 * @license GNU GPL 3.0 or any newer version
16 * @link http://www.shipsimu.org
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 interface DatabaseBackend extends FrameworkDatabase {
33 * Getter for last read file
35 * @return $lastFile The last read file's name with full path
37 function getLastFile ();
40 * Getter for last read file's content as an array
42 * @return $lastContent The array with elements 'header' and 'data'.
44 function getLastContents ();
47 * Getter for file extension
49 * @return $fileExtension The array with elements 'header' and 'data'.
51 function getFileExtension ();
54 * Getter for index key
56 * @return $indexKey Index key
58 function getIndexKey ();
61 * Makes sure that the database connection is alive
64 * @todo Do some checks on the database directory and files here
66 function connectToDatabase ();
69 * Starts a SELECT query on the database by given return type, table name
72 * @param $tableName Name of the database table
73 * @param $searchInstance Local search criteria class
74 * @return $resultData Result data of the query
75 * @throws UnsupportedCriteriaException If the criteria is unsupported
76 * @throws SqlException If an 'SQL error' occurs
78 function querySelect ($tableName, LocalSearchCriteria $searchInstance);
81 * "Inserts" a data set instance into a local file database folder
83 * @param $dataSetInstance A storeable data set
85 * @throws SqlException If an SQL error occurs
87 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
90 * "Updates" a data set instance with a database layer
92 * @param $dataSetInstance A storeable data set
94 * @throws SqlException If an SQL error occurs
96 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
99 * Getter for primary key of specified table or if not found null will be
100 * returned. This must be database-specific.
102 * @param $tableName Name of the table we need the primary key from
103 * @return $primaryKey Primary key column of the given table
105 function getPrimaryKeyOfTable ($tableName);
108 * Removes non-data from given array.
110 * @param $data An array with possible non-data that needs to be removed.
111 * @return $data A cleaned up array with only data.
112 * @todo Add more generic non-data for removal
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);