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 <<<<<<< HEAD:framework/main/interfaces/database/backend/class_DatabaseBackend.php
20 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
22 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
23 >>>>>>> Some updates::inc/main/interfaces/database/backend/class_DatabaseBackend.php
24 * @license GNU GPL 3.0 or any newer version
25 * @link http://www.shipsimu.org
27 * This program is free software: you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published by
29 * the Free Software Foundation, either version 3 of the License, or
30 * (at your option) any later version.
32 * This program is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
37 * You should have received a copy of the GNU General Public License
38 * along with this program. If not, see <http://www.gnu.org/licenses/>.
40 interface DatabaseBackend extends FrameworkDatabase {
42 * Getter for last read file
44 * @return $lastFile The last read file's name with full path
46 function getLastFile ();
49 * Getter for last read file's content as an array
51 * @return $lastContent The array with elements 'header' and 'data'.
53 function getLastContents ();
56 * Getter for file extension
58 * @return $fileExtension The array with elements 'header' and 'data'.
60 function getFileExtension ();
63 * Getter for index key
65 * @return $indexKey Index key
67 function getIndexKey ();
70 * Makes sure that the database connection is alive
73 * @todo Do some checks on the database directory and files here
75 function connectToDatabase ();
78 * Starts a SELECT query on the database by given return type, table name
81 * @param $tableName Name of the database table
82 * @param $searchInstance Local search criteria class
83 * @return $resultData Result data of the query
84 * @throws UnsupportedCriteriaException If the criteria is unsupported
85 * @throws SqlException If an 'SQL error' occurs
87 function querySelect ($tableName, LocalSearchCriteria $searchInstance);
90 * "Inserts" a data set instance into a local file database folder
92 * @param $dataSetInstance A storeable data set
94 * @throws SqlException If an SQL error occurs
96 function queryInsertDataSet (StoreableCriteria $dataSetInstance);
99 * "Updates" a data set instance with a database layer
101 * @param $dataSetInstance A storeable data set
103 * @throws SqlException If an SQL error occurs
105 function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
108 * Getter for primary key of specified table or if not found null will be
109 * returned. This must be database-specific.
111 * @param $tableName Name of the table we need the primary key from
112 * @return $primaryKey Primary key column of the given table
114 function getPrimaryKeyOfTable ($tableName);
117 * Removes non-data from given array.
119 * @param $data An array with possible non-data that needs to be removed.
120 * @return $data A cleaned up array with only data.
121 * @todo Add more generic non-data for removal
123 function removeNonPublicDataFromArray (array $data);
126 * Counts total rows of given table
128 * @param $tableName Table name
129 * @return $count Total rows of given table
131 function countTotalRows($tableName);