我是 CodeIgniter 的新手,在連接 db 后遇到以下錯誤。如果有人可以幫助我,那真是太好了。我檢查了 StackOverflow 中以前的答案,但沒有一個對我有幫助。下面是控制器代碼 <?phpdefined('BASEPATH') OR exit('No direct script access allowed');class Welcome extends MY_Controller { public function index() { $this->load->view('home'); } public function adminRegister() { //loading teh queries model $this->load->model('queries'); //Calling the getRoles function inside the roles $roles = $this->queries->getRoles(); print_r($roles); exit(); $this->load->view('register'); } public function login() { echo 'login'; }}型號代碼 <?php//Details of queries whicha re used to interact with teh databaseclass Queries extends CI_Model {//Created a function with the name getRoles public function getRoles() { //Fetch the reocrds from the table $roles = $this->db->get('tbl_roles'); if ($roles->num_rows() > 0) { return $roles->results(); } }}?>目前不使用來自控制器的數據。任何幫助將不勝感激。提前致謝。
1 回答

波斯汪
TA貢獻1811條經驗 獲得超4個贊
沒有結果應該是結果
參考CI 文檔
class Queries extends CI_Model {
//Created a function with the name getRoles
public function getRoles() {
//Fetch the reocrds from the table
$roles = $this->db->get('tbl_roles');
if ($roles->num_rows() > 0) {
return $roles->result();
}
}
}
- 1 回答
- 0 關注
- 130 瀏覽
添加回答
舉報
0/150
提交
取消