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