Opps, forgot this.
[core.git] / inc / classes / interfaces / database / backend / class_DatabaseBackend.php
1 <?php
2 /**
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.
8  *
9  * @author              Roland Haeder <webmaster@shipsimu.org>
10  * @version             0.0.0
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
14  *
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.
19  *
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.
24  *
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/>.
27  */
28 interface DatabaseBackend extends FrameworkDatabase {
29         /**
30          * Getter for last read file
31          *
32          * @return      $lastFile       The last read file's name with full path
33          */
34         function getLastFile ();
35
36         /**
37          * Getter for last read file's content as an array
38          *
39          * @return      $lastContent    The array with elements 'header' and 'data'.
40          */
41         function getLastContents ();
42
43         /**
44          * Getter for file extension
45          *
46          * @return      $fileExtension  The array with elements 'header' and 'data'.
47          */
48         function getFileExtension ();
49
50         /**
51          * Getter for index key
52          *
53          * @return      $indexKey       Index key
54          */
55         function getIndexKey ();
56
57         /**
58          * Makes sure that the database connection is alive
59          *
60          * @return      void
61          * @todo        Do some checks on the database directory and files here
62          */
63         function connectToDatabase ();
64
65         /**
66          * Starts a SELECT query on the database by given return type, table name
67          * and search criteria
68          *
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
74          */
75         function querySelect ($tableName, LocalSearchCriteria $searchInstance);
76
77         /**
78          * "Inserts" a data set instance into a local file database folder
79          *
80          * @param       $dataSetInstance        A storeable data set
81          * @return      void
82          * @throws      SqlException    If an SQL error occurs
83          */
84         function queryInsertDataSet (StoreableCriteria $dataSetInstance);
85
86         /**
87          * "Updates" a data set instance with a database layer
88          *
89          * @param       $dataSetInstance        A storeable data set
90          * @return      void
91          * @throws      SqlException    If an SQL error occurs
92          */
93         function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
94
95         /**
96          * Getter for primary key of specified table or if not found null will be
97          * returned. This must be database-specific.
98          *
99          * @param       $tableName              Name of the table we need the primary key from
100          * @return      $primaryKey             Primary key column of the given table
101          */
102         function getPrimaryKeyOfTable ($tableName);
103
104         /**
105          * Removes non-data from given array.
106          *
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
110          */
111         function removeNonPublicDataFromArray (array $data);
112
113         /**
114          * Counts total rows of given table
115          *
116          * @param       $tableName      Table name
117          * @return      $count          Total rows of given table
118          */
119         function countTotalRows($tableName);
120 }
121
122 // [EOF]
123 ?>