感謝幫助我的最後一個問題 我有我的主題類項目視圖在一個特殊的 類別看看我的功能在「主題」類中的所有主題的問題:得到
/*
* Get topics by Category
*/
public function getByCategory($category_id){
$this->db->query("SELECT topics.*, categories.*, users.username, users.avatar FROM topics
INNER JOIN categories
ON topics.category_id = categories.id
INNER JOIN users
ON topics.user_id = users.id
WHERE topics.category_id = :category_id
");
$his->db->bind(':category_id', $category_id);
//Assign Result Set
$results = $this->db->resultset();
return $results;
}
這是我的根文件夾topics.php
<?php require('core/init.php');?>
<?php
//create New Topic
$topic = new Topic;
//Get Category From URL
$category = isset($_GET['category']) ? $_GET['category'] : null;
//Get user From URL
$user_id = isset($_GET['user']) ? $_GET['user'] : null;
//Get Template & Assign Vars
$template = new Template('templates/topics.php');
//Assign Template Variables
if(isset($category)){
$template->topics = $topic->getByCategory($category);
$template->title = 'Posts In "'.$topic->getByCategory($category)->name.'"';
}
//Assign Template Variables
if(isset($user_id)){
$template->topics = $topic->getByUser($user_id);
$template->title = 'Posts By "'.$topic->getUser($user_id)->username.'"';
}
if(!isset($category) && !isset($user_id)){
$template->topics = $topic->getAllTopics();
}
//Assign vars
$template->totalTopics = $topic->getTotalTopics();
$template->totalCategories = $topic->getTotalCategories();
// display Template
echo $template;
?>
當我點擊一個類別的鏈接('topics.php類= 1?)有此錯誤:
Notice: Undefined variable: his in C:\xampp\htdocs\talkingspace\libraries\Topic.php on line 74
Notice: Trying to get property of non-object in C:\xampp\htdocs\talkingspace\libraries\Topic.php on line 74
Fatal error: Call to a member function bind() on null in C:\xampp\htdocs\talkingspace\libraries\Topic.php on line 74
我想也許我失敗了從數據庫的SELECT查詢。
任何幫助的最佳問候。
非常感謝 它的工作:) –
歡迎你@AliQorbani!請享用 – Saty