8c30d951ba22cd764e5ec86b2bdb939ccad9f016
[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 connect($host, $base, $user, $password){
18       return $this->sgbd_impl->connect($host, $base, $user, $password);
19     }
20
21     function select_db($db_name){
22       return $this->sgbd_impl->select_db($db_name);
23     }
24
25     # ---------------------------------------------------------------------------------
26     #                                                                               SQL
27     #
28
29     function table_exists($table_name){
30       return $this->sgbd_impl->table_exists(
31         ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
32           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $table_name)
33         : $table_name
34       );
35     }
36
37     function field_exists($table_name, $field_name){
38       return $this->sgbd_impl->field_exists(
39         (
40           $prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
41           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $table_name)
42         : $table_name,
43         $field_name
44       );
45
46     }
47
48     function query($sql){
49       return $this->sgbd_impl->query(
50         ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
51           str_replace($prefix_codes, array_values($this->env->bdd("table_prefix")), $sql)
52         : $sql
53       );
54     }
55
56     function insert_id(){
57       return $this->sgbd_impl->insert_id();
58     }
59
60     function fetch_assoc($rst){
61       return $this->sgbd_impl->fetch_assoc($rst);
62     }
63
64     function free_result($rst){
65       return $this->sgbd_impl->free_result($rst);
66     }
67
68     function close(){
69       return $this->sgbd_impl->close();
70     }
71
72     # ---------------------------------------------------------------------------------
73     #                                                                               XML
74     #
75
76     function data_exists($data_path){
77       return $this->sgbd_impl->data_exists($data_path);
78     }
79
80     function create_data($data_path){
81       return $this->sgbd_impl->create_data($data_path);
82     }
83
84     function get_data($data_path, $data_id){
85       return $this->sgbd_impl->get_data($data_path, $data_id);
86     }
87
88     function open_data($data_path, $FETCH = true){
89       return $this->sgbd_impl->open_data($data_path, $FETCH);
90     }
91
92     function fetch_data($dh){
93       return $this->sgbd_impl->fetch_data($dh);
94     }
95
96     function add_data($data_path, $data){
97       return $this->sgbd_impl->add_data($data_path, $data);
98     }
99
100     function last_index($dh){
101       return $this->sgbd_impl->last_index($dh);
102     }
103
104     function set_data($data_path, $data_id, $data){
105       return $this->sgbd_impl->set_data($data_path, $data_id, $data);
106     }
107
108     function del_data($data_path, $data_id){
109       return $this->sgbd_impl->del_data($data_path, $data_id);
110     }
111
112     function close_data($dh){
113       return $this->sgbd_impl->close_data($dh);
114     }
115
116     function remove_data($data_path){
117       return $this->sgbd_impl->remove_data($data_path);
118     }
119
120   }
121
122 ?>