문제

My small project with CodeIgniter (wich is only to get familiar with it. It's actually like their tutorial's example) it stoped working, giving me no output or errors even that in the index.php is set to developement...

So I tried to debug it myself with some echo's

And I found that here stops logging

class News extends CI_Controller {

    public function __construct()
    {

        parent::__construct();
        echo 'This is echoed';
        $this->load->model('news_model');
        echo 'This wont be echoed';
    }
        /*(class continues)*/
}

And my news_model.php looks like this:

<?php
class News_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }

    public function get_news($slug = FALSE)
    {
        if ($slug === FALSE)
        {
            $query = $this->db->get('news'{});
            return $query->result_array();
        }

        $query = $this->db->get_where('news', array('slug' => $slug));
        return $query->row_array();
    }

    public function set_news()
    {
        $this->load->helper('url');

        $slug = url_title($this->input->post('title'), 'dash', TRUE);

        $data = array(
            'title' => $this->input->post('title'),
            'slug' => $slug,
            'text' => $this->input->post('text')
        );

        return $this->db->insert('news', $data);
    }
}

Any idea what I'm doing wrong?

-EDIT-

public function __construct()
{
    echo '__construct()';
    $this->load->database();
    echo 'after__construct()';
}

None of them are echoed...

도움이 되었습니까?

해결책

find 1

$this->db->get('news'{});  //    try to del {}

first parameters is table name

The second and third parameters enable you to set a limit and offset clause

다른 팁

Original codeignitor tutorial has this:

public function get_news($slug = FALSE)
{
if ($slug === FALSE)
{
    $query = $this->db->get('news'); // <----------------------------
    return $query->result_array();
}

$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top