3 * An interface for front-end database classes. The classes should prepare the
4 * objects for saving in the database. So for server-bases database classes SQL
5 * queries shall be generated and send to the backend classes. In case of local
6 * file databases the object shall be serialized and (maybe) transparently
7 * compressed before they got saved to a local file.
9 * @author Roland Haeder <webmaster@shipsimu.org>
11 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
12 * @license GNU GPL 3.0 or any newer version
13 * @link http://www.shipsimu.org
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 interface DatabaseBackend extends FrameworkDatabase {
30 * Getter for last read file
32 * @return $lastFile The last read file's name with full path
34 function getLastFile ();
37 * Getter for last read file's content as an array
39 * @return $lastContent The array with elements 'header' and 'data'.
41 function getLastContents ();
44 * Getter for file extension
46 * @return $fileExtension The array with elements 'header' and 'data'.
48 function getFileExtension ();
51 * Getter for index key
53 * @return $indexKey Index key
55 function getIndexKey ();
58 * Makes sure that the database connection is alive
61 * @todo Do some checks on the database directory and files here
63 function connectToDatabase ();
66 * Starts a SELECT query on the database by given return type, table name
69 * @param $tableName Name of the database table
70 * @param $searchInstance Local search criteria class
71 * @return $resultData Result data of the query
72 * @throws UnsupportedCriteriaException If the criteria is unsupported
73 * @throws SqlException If an 'SQL error' occurs
75 function querySelect ($tableName, LocalSearchCriteria $searchInstance);
78 * "Inserts" a data set instance into a local file database folder
80 * @param $dataSetInstance A storeable data set
82 * @throws SqlException If an SQL error occurs
84 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
87 * "Updates" a data set instance with a database layer
89 * @param $dataSetInstance A storeable data set
91 * @throws SqlException If an SQL error occurs
93 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
96 * Getter for primary key of specified table or if not found null will be
97 * returned. This must be database-specific.
99 * @param $tableName Name of the table we need the primary key from
100 * @return $primaryKey Primary key column of the given table
102 function getPrimaryKeyOfTable ($tableName);
105 * Removes non-data from given array.
107 * @param $data An array with possible non-data that needs to be removed.
108 * @return $data A cleaned up array with only data.
109 * @todo Add more generic non-data for removal
111 function removeNonPublicDataFromArray (array $data);
114 * Counts total rows of given table
116 * @param $tableName Table name
117 * @return $count Total rows of given table
119 function countTotalRows($tableName);