verification de la version
[mtweb] / mw / app / data / mw_sgbd.php
1 <?php
2
3   class mw_sgbd{
4
5     var $sgbd_impl;
6     var $env;
7
8     function mw_sgbd($sgbd_impl, $env){
9       $this->sgbd_impl = $sgbd_impl;
10       $this->env = $env;
11     }
12
13     function extention_ok(){
14       return $this->sgbd_impl->extention_ok($this->env);
15     }
16
17     function authentication_required(){
18       return $this->sgbd_impl->authentication_required();
19     }
20
21     function connect($host, $base, $user, $password){
22       return $this->sgbd_impl->connect($host, $base, $user, $password);
23     }
24
25     function select_db($db_name){
26       return $this->sgbd_impl->select_db($db_name);
27     }
28
29     # ---------------------------------------------------------------------------------
30     #                                                                               SQL
31     #
32
33     function desc_table($table_name){
34       if(!method_exists($this->sgbd_impl, "desc_table")) return false;
35       return $this->sgbd_impl->desc_table(
36         ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
37           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $table_name)
38         : $table_name
39       );
40     }
41
42     function table_exists($table_name){
43       if(!method_exists($this->sgbd_impl, "table_exists")) return false;
44       return $this->sgbd_impl->table_exists(
45         ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
46           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $table_name)
47         : $table_name
48       );
49     }
50
51     function field_exists($table_name, $field_name){
52       if(!method_exists($this->sgbd_impl, "field_exists")) return false;
53       return $this->sgbd_impl->field_exists(
54         (
55           $prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
56           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $table_name)
57         : $table_name,
58         $field_name
59       );
60     }
61
62     function query($sql){
63       if(!method_exists($this->sgbd_impl, "query")) return false;
64       return $this->sgbd_impl->query(
65         ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
66           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $sql)
67         : $sql
68       );
69     }
70
71     function insert_id(){
72       if(!method_exists($this->sgbd_impl, "insert_id")) return false;
73       return $this->sgbd_impl->insert_id();
74     }
75
76     function fetch_assoc($rst){
77       if(!method_exists($this->sgbd_impl, "fetch_assoc")) return false;
78       return $this->sgbd_impl->fetch_assoc($rst);
79     }
80
81     function free_result($rst){
82       if(!method_exists($this->sgbd_impl, "")) return false;
83       return $this->sgbd_impl->free_result($rst);
84     }
85
86     function close(){
87       if(!method_exists($this->sgbd_impl, "")) return false;
88       return $this->sgbd_impl->close();
89     }
90
91     # ---------------------------------------------------------------------------------
92     #                                                                               XML
93     #
94
95     function data_exists($data_path){
96       if(!method_exists($this->sgbd_impl, "data_exists")) return false;
97       return $this->sgbd_impl->data_exists($data_path);
98     }
99
100     function create_data($data_path){
101       if(!method_exists($this->sgbd_impl, "create_data")) return false;
102       return $this->sgbd_impl->create_data($data_path);
103     }
104
105     function get_data($data_path, $data_id){
106       if(!method_exists($this->sgbd_impl, "get_data")) return false;
107       return $this->sgbd_impl->get_data($data_path, $data_id);
108     }
109
110     function open_data($data_path, $FETCH = true){
111       if(!method_exists($this->sgbd_impl, "open_data")) return false;
112       return $this->sgbd_impl->open_data($data_path, $FETCH);
113     }
114
115     function fetch_data($dh){
116       if(!method_exists($this->sgbd_impl, "fetch_data")) return false;
117       return $this->sgbd_impl->fetch_data($dh);
118     }
119
120     function add_data($data_path, $data, $index = null){
121       if(!method_exists($this->sgbd_impl, "add_data")) return false;
122       return $this->sgbd_impl->add_data($data_path, $data, $index);
123     }
124
125     function last_index($dh){
126       if(!method_exists($this->sgbd_impl, "last_index")) return false;
127       return $this->sgbd_impl->last_index($dh);
128     }
129
130     function set_data($data_path, $data_id, $data){
131       if(!method_exists($this->sgbd_impl, "set_data")) return false;
132       return $this->sgbd_impl->set_data($data_path, $data_id, $data);
133     }
134
135     function del_data($data_path, $data_id){
136       if(!method_exists($this->sgbd_impl, "del_data")) return false;
137       return $this->sgbd_impl->del_data($data_path, $data_id);
138     }
139
140     function close_data($dh){
141       if(!method_exists($this->sgbd_impl, "close_data")) return false;
142       return $this->sgbd_impl->close_data($dh);
143     }
144
145     function remove_data($data_path){
146       if(!method_exists($this->sgbd_impl, "remove_data")) return false;
147       return $this->sgbd_impl->remove_data($data_path);
148     }
149
150   }
151
152 ?>