CodeIgniter

0

Не могу понять, в чем дело. Не выводит новости в браузер. Вот код:

News.php

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class News extends CI_Controller {
	public function __constract() {
		parent:: __constract();
		$this->load->model('news_model');
	}

	public function index() {
			$data['title'] = "Все новости";
			$data['news'] = $this->news_model->getNews();

			$this->load->view('templates/header', $data);
			$this->load->view('news/index', $data);
			$this->load->view('templates/footer');
	}	
	
}

News_model.php

<?php

	class News_model extends CI_Model {
		public function __conatract() {
			$this->load->database();
		}

		public function getNews($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();
		}
		
	}
	
?>

database.php(кусочек)

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => '',
	'database' => 'sovietfilms',
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (ENVIRONMENT !== 'production'),
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

i

<h1>Все новости</h1>

<?php foreach ($news as $key => $value): ?>
	<h2><?php echo $value['title']; ?> </h2>
<?php endforeach ?>

ndex.php

Codeigniter

1 ответов

2

Ошибка в ключевом слове:

__conatract() 

должно быть

__construct()

Sign up or Log in to write an answer