Авторизация

_connect(); } public function _connect() { //include("config/config.php"); $this->connect = mysql_connect(HOST, USER, PASSWORD) or die(mysql_error()); $this->_selectdb(DB); mysql_query('SET character_set_database = utf8'); mysql_query('SET NAMES utf8'); } public function _selectdb($db) { $this->db = $db; mysql_select_db($db) or die(mysql_error()); } public static function gI() { return (self::$instance === null) ? self::$instance = new self() : self::$instance; } public function query($q) { //echo $q.'
'; $this->query = $q; $this->count++; $this->result = mysql_query($q) or die(mysql_error()); return $this->result; } public function select($fields, $table, $if = null, $by = null) { $this->query = "SELECT $fields FROM $table $if $by"; return $this->query($this->query); } public function insert($table, $values, $fields = NULL) { $fields = ($fields != NULL) ? "($fields)" : NULL; $this->query = "INSERT INTO $table $fields VALUES ($values)"; //echo $this->query."
"; return $this->query($this->query); } public function insert_id() { return mysql_insert_id(); } public function update($table, $set, $if) { $this->query = "UPDATE $table SET $set WHERE ($if)"; return $this->query($this->query); } public function delete($table, $if) { $this->query = "DELETE FROM $table WHERE ($if)"; return $this->query($this->query); } public function gra() { $this->array = mysql_fetch_assoc($this->result); return $this->array; } public function get_row_array($res, $flag = true) { if ($flag === true) { return mysql_fetch_assoc($res); } else { return mysql_fetch_array($res); } } public function fields($table) { $list = mysql_list_fields($this->db, $table, $this->connect); $n = mysql_num_fields($list); for ($i = 0; $i < $n; $i++) { $arr[$i] = mysql_field_name($list, $i); } return $arr; } function mysql_table_seek($tablename) { $res = $this->query("SHOW TABLES FROM `" . $this->db . "`"); while ($row = $this->get_row_array($res, false)) { if ($tablename == $row[0]) { return true; break; } } return false; } public function ren_table($oldname, $newname) { $this->query = "RENAME TABLE `$oldname` TO `$newname`;"; return $this->query($this->query); } public function deltable($table) { $this->query = "DROP TABLE `$table`"; return $this->query($this->query); } public function addfield($table, $field_name, $type) { $this->query = "ALTER TABLE `$table` ADD `$field_name` $type"; //echo $this->query."
"; return $this->query($this->query); } public function renfield($oldname, $newname, $table, $type) { $this->query = "ALTER TABLE `$table` CHANGE `$oldname` `$newname` $type"; return $this->query($this->query); } } ?>