14 function extention_ok(&$env) { return $this->EXTENTION_OK; }
16 function mw_mysql($host, $base, $user, $password)
17 { $this->host = $host;
20 $this->password = $password;
21 $this->EXTENTION_OK = function_exists("mysql_connect");
24 function connect($host, $base, $user, $password)
25 { $this->link = @mysql_connect($host, $user, $password);
26 if(!$this->link) return null;
27 @mysql_query("SET NAMES 'utf8'");
29 { $connected = @mysql_select_db($base, $this->link);
30 if(!$connected) return null;
35 function select_db($db_name)
36 { $this->base = $db_name;
38 { if(!$this->connect($this->host, $this->base, $this->user, $this->password)) return null;
40 return $this->query("USE ".$db_name);
43 function table_exists($table_name)
44 { $sql = "SHOW TABLES LIKE '".$table_name."'";
45 $rst = $this->query($sql);
48 $v_rst = $this->fetch_assoc($rst);
49 if($v_rst) $exists = true;
50 $this->free_result($rst);
56 function query($query_string)
58 { if(!$this->connect($this->host, $this->base, $this->user, $this->password)) return null;
60 $result = @mysql_query($query_string, $this->link);
61 if(!$result) return null;
65 function fetch_assoc($rst)
66 { if($rst && $this->link) return mysql_fetch_assoc($rst);
71 { if($this->link) return mysql_insert_id($this->link);
75 function free_result($rst)
76 { if($rst && $this->link) return mysql_free_result($rst);
81 { if($this->link) return mysql_close($this->link);