/
golost
/
QaManagerBotBackend
Обзор
Документация
Войти
/
golost
/
QaManagerBotBackend
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app1/api/objects/qa.php
91 строка
2 KB
olegnizh
Добавьте файлы проекта.
05 июн 2024, 16:06
05 июн 2024, 16:06
8ef4523
Код
Авторство
О чём код?
<?php class Qa{ private $conn; private $table_name = "qas"; public $qaid; public $quest; public $answ; public $hyper; public $active; public function __construct($db){ $this->conn = $db; } function read(){ $query = "SELECT `qaid`, `quest`, `answ`, `hyper`, `active` FROM " . $this->table_name . " ORDER BY qaid DESC"; $stmt = $this->conn->prepare($query); $stmt->execute(); return $stmt; } function read_single(){ $query = "SELECT `qaid`, `quest`, `answ`, `hyper`, `active` FROM " . $this->table_name . " WHERE qaid= '".$this->qaid."'"; $stmt = $this->conn->prepare($query); $stmt->execute(); return $stmt; } function create(){ $query = "INSERT INTO ". $this->table_name ." (`qaid`, `quest`, `answ`, `hyper`, `active`) VALUES ('".$this->qaid."', '".$this->quest."', '".$this->answ."', '".$this->hyper."', '".$this->active."')"; $stmt = $this->conn->prepare($query); if($stmt->execute()){ $this->id = $this->conn->lastInsertId(); return true; } return false; } function update(){ $query = "UPDATE " . $this->table_name . " SET quest='".$this->quest."', answ='".$this->answ."', hyper='".$this->hyper."', active='".$this->active."' WHERE qaid='".$this->qaid."'"; $stmt = $this->conn->prepare($query); if($stmt->execute()){ return true; } return false; } function delete(){ $query = "DELETE FROM " . $this->table_name . " WHERE qaid= '".$this->qaid."'"; $stmt = $this->conn->prepare($query); if($stmt->execute()){ return true; } return false; } }