source: branches/2.2.0.1/calendar/js/dhtmlx/codebase/connector/db_mysqli.php @ 4001

Revision 4001, 1.3 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1<?php
2
3require_once("db_common.php");
4
5class MySQLiDBDataWrapper extends MySQLDBDataWrapper{
6
7        public function query($sql){
8                LogMaster::log($sql);
9                $res = $this->connection->query($sql);
10                if ($res===false) throw new Exception("MySQL operation failed\n".$this->connection->error);
11                return $res;
12        }
13
14        public function get_next($res){
15                return $res->fetch_assoc();
16        }
17
18        protected function get_new_id(){
19                return $this->connection->insert_id;
20        }
21
22        public function escape($data){
23                return $this->connection->real_escape_string($data);
24        }
25
26        public function tables_list() {
27                $result = $this->connection->query("SHOW TABLES");
28                if ($result===false) throw new Exception("MySQL operation failed\n".$this->connection->error);
29
30                $tables = array();
31                while ($table = $result->fetch_array()) {
32                        $tables[] = $table[0];
33                }
34                return $tables;
35        }
36
37        public function fields_list($table) {
38                $result = $this->connection->query("SHOW COLUMNS FROM `".$table."`");
39                if ($result===false) throw new Exception("MySQL operation failed\n".$this->connection->error);
40                $fields = array();
41                while ($field = $result->fetch_array()) {
42                        if ($field['Key'] == "PRI") {
43                                $fields[$field[0]] = 1;
44                        } else {
45                                $fields[$field[0]] = 0;
46                        }
47                }
48                return $fields;
49        }
50
51}
52
53?>
Note: See TracBrowser for help on using the repository browser.