[eluser]Kolin[/eluser]
Hi There,
I'm just in the process of learning OOphp and codeigniter
This is a bit of a nub question im sure but i cant figure it out.
I'm using the array $data[] to send data to my view.
I want to add the section name to $data['section'] for all functions in the model but it wont work.
The error i get it
Quote:Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/compirc/public_html/development/system/application/models/articlemodel.php on line 9
The code i'm using is
Code:
<?php
// model
// articles.php
//
class Articlemodel extends Model {
var $data['section'] = "articles";
function __construct() {
parent::__construct();
}
function getCategories(){
$query = $this->db->query("SELECT * FROM article_categories");
$categories = $query->result_array();
$data['categories'] = $categories;
return $data;
}
function getArticles(){
$category = $this->uri->segment(3);
$query = $this->db->query("SELECT users.username, articles.id, articles.name, articles.description, articles.author_id, articles.created FROM articles LEFT JOIN users ON articles.author_id = users.id WHERE category_id = $category");
$articles = $query->result_array();
$data['articles'] = $articles;
return $data;
}
function getArticle(){
$article = $this->uri->segment(3);
$query = $this->db->query("SELECT * from articles where id = $article");
$article = $query->row();
$data['article'] = $article;
return $data;
}
}
?>
Any help on how to get this to work, or a better way to go about it would be appreciated.
Thanks,
Kolin