Добрый день!Возникла такая ошибка! Allowed memory size of 1610612736 bytes exhausted (tried to allocate 1073741832 bytes), in W:\domains\foto.loc\lib\db_class.php on line 61.не понимаю почему она возникла,так как я вытаскиваю всего лишь одну строку. вот код: PHP: ini_set('memory_limit', '1024M'); class DB { protected $mysqli; protected $host; protected $root; protected $password; protected $db; public function __construct($host, $root, $password, $db) { $this->host = $host; $this->root = $root; $this->password = $password; $this->db = $db; $this->mysqli = new mysqli($this->host, $this->root, $this->password, $this->db); $this->mysqli->set_charset('utf8'); } private static function string($field,$value) { $field = "`".implode('`, `', explode(',', $field))."`"; $value = "'".$value."'"; $array = [$field => $value]; return $array; } private static function where($field,$value) { if ((strpos($field, "id")) !== false) { $str = self::string($field, $value); foreach ($str as $key => $v) $str = $key.' = '.$v; $request = "WHERE ".$str; } else{ if ((is_string($field)) && (strlen($field) != 0)) { $str = self::string($field, $value); foreach ($str as $key => $v) $str = $key.' = '.$v; $request = "WHERE ".$str; } } return $request; } public function select($table_name, $field, $where = false, $field_where = null, $value_where = null) { $str = self::string($table_name, $field); foreach ($str as $key => $v) if (!$where) { foreach ($str as $key => $v) $request = "SELECT ".$v." FROM ".$key; return $request; } elseif ($where) { $str_where = self::string($field_where, $value_where); foreach ($str_where as $key_where => $v_where) $str_where = $key_where.' = '.$v_where; $request = "SELECT ".$v." FROM ".$key." WHERE ".$str_where; $query = $this->mysqli->query($request); if (!$query) return false; else { $arr = []; while (($row = $query->fetch_assoc()) !== false) $arr[] = $row; } } } public function __destruct() { if (($this->mysqli) && (!$this->mysqli->connect_errno)) $this->mysqli->close(); } } Вызываю метод из другого файла PHP: require_once 'db_class.php'; $db = new DB("localhost", "root", "", "test"); $db->select("users","name", true, "age", "14"); Ошибка происходит вот тут PHP: $arr[] = $row;
ошибка Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1073741832 bytes) in W:\domains\foto.loc\lib\db_class.php on line 61 я изменил выше код
эта ошибка значит, что не хватает оперативной памяти вряд ли проблема в этом классе что выше? что делаешь вообще?
цикл будет выводить данные,пока их не станет,то есть пока не будет false --- Добавлено --- я пытаюсь реализовать класс,в котором будут методы select,update,delete,where,order
если убрать Код (Text): !== false ,то выводится массив Array ( [name] => name ),но данные не те,которые в БД --- Добавлено --- Блин,как раз в буфер,как же мне быть,как исправить ошибку?