Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter查询WordPress博客_Php_Mysql_Wordpress_Codeigniter - Fatal编程技术网

Php CodeIgniter查询WordPress博客

Php CodeIgniter查询WordPress博客,php,mysql,wordpress,codeigniter,Php,Mysql,Wordpress,Codeigniter,我终于尝试了我的手在某个代码点火器,我现在卡住了 新闻模型 控制器 与数据库的连接正常,但我只返回show_404()在我看来,因为没有记录 直接对数据库运行类似的查询确实会返回我的所有记录 以下是变量转储的结果: object(CI_DB_mysql_result)#18 (8) { ["conn_id"]=> resource(3) of type (mysql link persistent) ["result_id"]=>

我终于尝试了我的手在某个代码点火器,我现在卡住了

新闻模型 控制器 与数据库的连接正常,但我只返回
show_404()在我看来,因为没有记录

直接对数据库运行类似的查询确实会返回我的所有记录

以下是
变量转储的结果:

object(CI_DB_mysql_result)#18 (8) { 
   ["conn_id"]=> resource(3) of type (mysql link persistent) 
   ["result_id"]=> resource(4) of type (mysql result) 
   ["result_array"]=> array(0) { } 
   ["result_object"]=> array(0) { } 
   ["custom_result_object"]=> array(0) { } 
   ["current_row"]=> int(0) ["num_rows"]=> int(0)
   ["row_data"]=> NULL 
}

我做错了什么?

更改:
$this->db->where('post_status','published')

收件人:
$this->db->where('post_status','publish')


问题解决了。。。漫长的一周…

p.s.我的
路线是合适的。。。最初,他们在CodeIgnitor网站上遵循
新闻
教程
class News extends CI_Controller{
    
    public function __construct(){
        parent::__construct();
        // located @ /application/models/news_model.php
        $this->load->model('news_model');   
    }
    
    // pull in all news items
    public function index(){
        $data['news'] = $this->news_model->get_news();
        // give the page a title
        $data['title'] = 'Articles Archive';
        $data['c_year'] = date('Y');
        // Load the header template
        $this->load->view('templates/header', $data);
        // Load the page
        $this->load->view('news/index', $data);
        // Load the footer template
        $this->load->view('templates/footer', $data);
    }
    
    // pull in only the news item(s) where the slug matches
    public function view($slug){
        $data['news_item'] = $this->news_model->get_news($slug);
        // give the page a title
        $data['title'] = $data['news_item']['title'];
        $data['c_year'] = date('Y');
        // Load the header template
        $this->load->view('templates/header', $data);
        // Load the page
        $this->load->view('news/view', $data);
        // Load the footer template
        $this->load->view('templates/footer', $data);
    }
        
}
object(CI_DB_mysql_result)#18 (8) { 
   ["conn_id"]=> resource(3) of type (mysql link persistent) 
   ["result_id"]=> resource(4) of type (mysql result) 
   ["result_array"]=> array(0) { } 
   ["result_object"]=> array(0) { } 
   ["custom_result_object"]=> array(0) { } 
   ["current_row"]=> int(0) ["num_rows"]=> int(0)
   ["row_data"]=> NULL 
}