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