Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.88/16: Рейтинг темы: голосов - 16, средняя оценка - 4.88
133 / 133 / 48
Регистрация: 26.04.2013
Сообщений: 1,356
1

Fatal error: Call to undefined method DataBase

10.05.2013, 02:56. Показов 3027. Ответов 2
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Всем доброй ночи,помогите найти ошибку


Fatal error: Call to undefined method DataBase::existstID() in Z:\home\test.local\www\lib\database_class.php on line 129


PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
require_once "config_class.php";
require_once "checkvalid_class.php";
 
class DataBase {
    
    private $config;
    private $mysqli;
    private $valid;
    
    public function __construct() {
        $this->config = new Config ();
        $this->valid = new CheckValid();
        $this->mysqli = new mysqli($this->config->host, $this->config->user, $this->config->password, $this->config->db);
        $this->mysqli->query("SET NAMES 'utf8'");
    }
    
    private function query($query) {
        return $this->mysqli->query($query);
    }
    
    private function select($table_name, $fields, $where = "", $order = "", $up = true, $limit = "") {
        for ($i = 0; $i < count ($fields); $i++)  {
            if ((strpos($fields[$i], "(") === false) && ($fields[$i] != "*")) $fields[$i] = "`".$fields[$i]."`";
        }
        $fields = implode(",",$fields);
        $table_name = $this->config->db_prefix.$table_name;
        if (!$order) $order = "ORDER BY `id`";
        else {
            if ($order != "RAND()") {
                $order = "ORDER BY `$order`";
                if (!up) $order .= " DESC";
            }
            else $order = "ORDER BY $order";
    }
    if ($limit) $limit = "LIMIT $limit";
    if ($where) $query = "SELECT $fields FROM $table_name WHERE $where $order $limit";
    else $query = "SELECT $fields FROM $table_name $order $limit";
    $result_set = $this->query($query);
    if (!$result_set) return false;
    $i = 0;
    while ($row = $result_set->fetch_assoc()) {
        $data[$i] = $row;
        $i++;
    }
    $result_set->close();
    return $data;
    }
    
    public function insert ($table_name, $new_values) {
        $table_name = $this->config->db_prefix.$table_name;
        $query = "INSERT INTO $table_name (";
        foreach ($new_values as $field => $value) $query .= "`".$field."`,";
        $query = substr($query, 0, -1);
        $query /= ") VALUES (";
        foreach ($new_values as $value) $query .= "'".addslashes($value)."',";
        $query = substr($query, 0, -1);
        $query .= ")";
        return $this->query($query);
    }
    
    private function update($table_name, $upd_fields, $where) {
        $table_name = $this->config->db_prefix.$table_name;
        $query = "UPDATE $table_name SET";
        foreach ($upd_fields as $field => $value) $query .= "`$field` = '".addslashes($value)."',";
        $query = substr($query, 0, -1);
        if ($where) {
            $query .= " WHERE $where";
            return $this->query($query);
        }
        else return false;
    }
    
    public function delete($table_name, $where = "") {
        $table_name = $this->config->db_prefix.$table_name;
        if ($where) {
            $query = "DELETE FROM $table_name WHERE $where";
            return $this->query($query);
        }
        else return false;
    }
    
    public function deleteAll ($table_name) {
        $table_name = $this->config->db_prefix.$table_name;
        $query = "TRUNCATE TABLE `$table_name`";
        return $this->query($query);
    }
    
    public function getField($table_name, $field_out, $field_in, $value_in) {
        $data = $this->select($table_name, array($field_out), "`$field_in`='".addslashes($value_in)."'");
        if (count($data) != 1) return false;
        return $data[0][$field_out];
    }
    
    public function getFieldOnID($table_name, $id, $field_out) {
        if (!$this->exitsID($table_name, $id)) return false;
        return $this->getField($table_name, $field_out, "id", $id);
    }
    
    public function getAll($table_name, $order, $up) {
        return $this->select($table_name, array("*"), "",$order, $up);
    }
    
    public function getAllOnField($table_name, $field, $value, $order, $up) {
         return $this->select($table_name, array("*"), "`$field_in`='".addslashes($value_in)."'", $order, $up);  
    }
    
    public function getLastID($table_name) {
         $data = $this->select($table_name, array("MAX (`id`"));
         return $data[0]["MAX(`id`)"];   
    }
    
    public function deleteOnID($table_name, $id) {
        if (!$this->exitsID($table_name, $id)) return false;
        return $this->delete($table_name, "`id` = '$id'");
 
    }
    
    public function setField($table_name, $field, $value, $field_in, $value_in) {
        return $this->update($table_name, array ($field => $value), "`$field_in` = '".addslashes($value_in)."'");
    }
    
    public function setFieldOnID($table_name, $id, $field, $value) {
        if (!$this->existstID($table_name,$id)) return false;
        return $this->setField($table_name, $field, $value, "id", $id);
    }
    
    public function getElementOnID($table_name, $id) {
        if (!$this->existstID($table_name, $id)) return false;
        $arr = $this->select($table_name, array("*"), "`id` = '$id'");
        return $arr[0];
    }
    
    public function getRandomElements($table_name, $count) {
        return $this->select($table_name, array("*"), "", "RAND()",true, $count);
    }
    
    public function getCount($table_name) {
        $data = $this->select($table_name, array("COUNT(`id`)"));
        return $data[0]["COUNT(`id`)"];
    }
    
    public function isExists($table_name, $field, $value) {
        $data = $this->select($table_name, array("id"), "`$field` = '".addslashes($value_in)."'");
        if (count($data) === 0) return false;
        return true;
    }
    
     private function existsID($table_name, $id) {
         if (!$this->valid->validID($id)) return false;
         $data = $this->select($table_name, array("id"), "`$field` = '".addslashes($id)."'");
         if (count($data) === 0) return false;
         return true;
     }
     
     public function __destruct() {
         if ($this->mysqli) $this->mysqli->close();
     }
     
     
    
    
 
}
 
?>
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
10.05.2013, 02:56
Ответы с готовыми решениями:

Fatal error: Call to undefined method
что это за ошибка? и как её лечить? Fatal error: Call to undefined method...

Fatal error: Call to undefined method ::getPath() in
В работе модуля возникла ошибка: Огромная Просьба подсказать решение.

Uncaught Error: Call to undefined method Error::loadModel()
Проблема такая. Когда я перехожу по несуществующей ссылке например: localhost/url меня перекидывает...

PHP Fatal error: Uncaught Error: Call to undefined function mb_strlen()
У меня в файлах запускаемых кроном используется функция mb_strlen(), когда заметил что скрипт не...

2
Почетный модератор
Эксперт HTML/CSSЭксперт PHP
16844 / 6723 / 880
Регистрация: 12.06.2012
Сообщений: 19,967
10.05.2013, 03:04 2
а вы не видите..?
Цитата Сообщение от maruo Посмотреть сообщение
if (!$this->existstID(
Цитата Сообщение от maruo Посмотреть сообщение
function existsID
1
133 / 133 / 48
Регистрация: 26.04.2013
Сообщений: 1,356
10.05.2013, 03:16  [ТС] 3
Вот ж Блин, такие нелепые ошибки)
Благодарю еще раз)
0
10.05.2013, 03:16
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
10.05.2013, 03:16
Помогаю со студенческими работами здесь

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
Всем привет! Знаю, проблема обсосана со всех сторон. Получаю вот это: PHP Fatal error: ...

Fatal error: Uncaught Error: Call to undefined function get_products()
Осваиваю разработку интернет магазина по видеокурсу, но возникают ошибки, которые никак не могу...

Fatal error: Uncaught Error: Call to undefined function can_upload()
Собрал конструктор тут не большой ... В БД отлично все уходит но фотки в папку не сохраняются...

Fatal Error: Call to undefined function ...
подскажите в чем ошибка? &lt;? if(!$_GET){ $k_post = mysql_result(mysql_query(&quot;SELECT COUNT(*)...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru