summaryrefslogtreecommitdiffstats
path: root/codebase/DataStorage/DataWrapper.php
blob: 19158cc43f9c6580661dad3a269d1ffa7f056eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php

namespace DHTMLX\Connector\DataStorage;
/*! Base abstraction class, used for data operations
	Class abstract access to data, it is a base class to all DB wrappers
**/
abstract class DataWrapper{
    protected $connection;
    protected $config;//!< DataConfig instance
    /*! constructor
        @param connection
            DB connection
        @param config
            DataConfig instance
    */
    public function __construct($connection = false,$config = false){
        $this->config=$config;
        $this->connection=$connection;
    }

    /*! insert record in storage

        @param data
            DataAction object
        @param source
            DataRequestConfig object
    */
    abstract function insert($data,$source);

    /*! delete record from storage

        @param data
            DataAction object
        @param source
            DataRequestConfig object
    */
    abstract function delete($data,$source);

    /*! update record in storage

        @param data
            DataAction object
        @param source
            DataRequestConfig object
    */
    abstract function update($data,$source);

    /*! select record from storage

        @param source
            DataRequestConfig object
    */
    abstract function select($source);

    /*! get size of storage

        @param source
            DataRequestConfig object
    */
    abstract function get_size($source);

    /*! get all variations of field in storage

        @param name
            name of field
        @param source
            DataRequestConfig object
    */
    abstract function get_variants($name,$source);

    /*! checks if there is a custom sql string for specified db operation

        @param  name
            name of DB operation
        @param  data
            hash of data
        @return
            sql string
    */
    public function get_sql($name,$data){
        return ""; //custom sql not supported by default
    }

    /*! begins DB transaction
    */
    public function begin_transaction(){
        throw new Exception("Data wrapper not supports transactions.");
    }
    /*! commits DB transaction
    */
    public function commit_transaction(){
        throw new Exception("Data wrapper not supports transactions.");
    }
    /*! rollbacks DB transaction
    */
    public function rollback_transaction(){
        throw new Exception("Data wrapper not supports transactions.");
    }
}