<?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);
}
}
?>
A PHP Error was encounteredSeverity: Notice Message: Undefined property: News:news_model Filename: controllers/News.php Line Number: 13 Backtrace: File: /Users/laijh/Sites/CI_practise/application/controllers/News.php
Line: 13
Function: _error_handler File: /Users/laijh/Sites/index.php
Line: 315
Function: require_once
An uncaught Exception was encounteredType: Error Message: Call to a member function get_news() on null Filename: /Users/laijh/Sites/CI_practise/application/controllers/News.php Line Number: 13 Backtrace: File: /Users/laijh/Sites/index.php
Line: 315
Function: require_once
|