モデルに対してクエリを実行しようとしましたが、エラーが発生しました。クエリをコントローラーに入れると、正常に動作します。これは私のコントローラ(Home.php)です:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('asset');
$this->load->database();
$this->load->library('table');
}
public function index()
{
$this->load->model('News');
$resultNews = $this->News->queryNews();
$data['resultNews'] = $resultNews;
$this->load->view('front/index',$data);
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
これは私のモデル(News.php)です:
<?php
if( !defined('BASEPATH')) exit('No direct script access allowed');
class News extends CI_Model {
function __construct(){
parent::__construct();
$this->load->database();
}
function queryNews(){
$this->db->query("SELECT * FROM `news` WHERE news_show_date >= CURDATE() ORDER BY news_show_date DESC LIMIT 0 , 2");
$query = $this->db->get();
return $query;
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
?>
そして、それはエラーを吐き出しています:
A Database Error Occurred
Error Number: 1096
No tables used
SELECT *
Filename: C:\AppServ\www\hijet\system\database\DB_driver.php
Line Number: 330
私は何か間違ったことをしていて、それを見逃していますか?