Fatal error: Call to a member function query() on a non-object
Report.php
class Report
{
public function remove($id){
$query = "DELETE FROM `logs` WHERE `id` = '".intval($id)."'";
$stmt = DB::query($query);
}
public function getAll(){
$stmt = DB::query("SELECT * FROM `logs`");
$data = array();
foreach($stmt->fetchAll() as $row){
$data[$row['id']] = $row['text'];
}
return $data;
}
}
index.php
if(isset($_POST['del_id'])){
//удаляем отчет
$report = new Report();
var_dump($report->remove($_POST['del_id']));
}
//получаем массив со всеми отчетами
$report = new Report();
$allreports = $report->getAll();
var_dump($allreports);