Continued:
[core.git] / inc / main / interfaces / database / backend / class_DatabaseBackend.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Database\Backend;
4
5 // Import framework stuff
6 use CoreFramework\Criteria\Local\LocalSearchCriteria;
7 use CoreFramework\Criteria\Storing\StoreableCriteria;
8 use CoreFramework\Database\FrameworkDatabase;
9
10 /**
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.
16  *
17  * @author              Roland Haeder <webmaster@shipsimu.org>
18  * @version             0.0.0
19  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
20  * @license             GNU GPL 3.0 or any newer version
21  * @link                http://www.shipsimu.org
22  *
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.
27  *
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.
32  *
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/>.
35  */
36 interface DatabaseBackend extends FrameworkDatabase {
37         /**
38          * Getter for last read file
39          *
40          * @return      $lastFile       The last read file's name with full path
41          */
42         function getLastFile ();
43
44         /**
45          * Getter for last read file's content as an array
46          *
47          * @return      $lastContent    The array with elements 'header' and 'data'.
48          */
49         function getLastContents ();
50
51         /**
52          * Getter for file extension
53          *
54          * @return      $fileExtension  The array with elements 'header' and 'data'.
55          */
56         function getFileExtension ();
57
58         /**
59          * Getter for index key
60          *
61          * @return      $indexKey       Index key
62          */
63         function getIndexKey ();
64
65         /**
66          * Makes sure that the database connection is alive
67          *
68          * @return      void
69          * @todo        Do some checks on the database directory and files here
70          */
71         function connectToDatabase ();
72
73         /**
74          * Starts a SELECT query on the database by given return type, table name
75          * and search criteria
76          *
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
82          */
83         function querySelect ($tableName, LocalSearchCriteria $searchInstance);
84
85         /**
86          * "Inserts" a data set instance into a local file database folder
87          *
88          * @param       $dataSetInstance        A storeable data set
89          * @return      void
90          * @throws      SqlException    If an SQL error occurs
91          */
92         function queryInsertDataSet (StoreableCriteria $dataSetInstance);
93
94         /**
95          * "Updates" a data set instance with a database layer
96          *
97          * @param       $dataSetInstance        A storeable data set
98          * @return      void
99          * @throws      SqlException    If an SQL error occurs
100          */
101         function queryUpdateDataSet (StoreableCriteria $dataSetInstance);
102
103         /**
104          * Getter for primary key of specified table or if not found null will be
105          * returned. This must be database-specific.
106          *
107          * @param       $tableName              Name of the table we need the primary key from
108          * @return      $primaryKey             Primary key column of the given table
109          */
110         function getPrimaryKeyOfTable ($tableName);
111
112         /**
113          * Removes non-data from given array.
114          *
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
118          */
119         function removeNonPublicDataFromArray (array $data);
120
121         /**
122          * Counts total rows of given table
123          *
124          * @param       $tableName      Table name
125          * @return      $count          Total rows of given table
126          */
127         function countTotalRows($tableName);
128
129 }