[eluser]Déjà Vu[/eluser]
Here is the whole model
Code:
<?
class mdl_comments extends Model {
var $commentid;
var $postid;
var $date;
var $author;
var $comment;
var $emailaddress;
var $url;
var $urltitle;
var $page;
var $limit;
var $numpages;
var $paginate;
function mdl_comments() {
parent::Model();
$this->limit = 20;
}
function get() {
$this->load->library('HTMLPurifier');
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set('Core', 'Encoding', 'UTF-8'); // replace with your encoding
$clean_comment = $this->htmlpurifier->purify($comment ,$purifier_config);
$comment = $clean_comment;
// before we set a limit / offset, we should grab all results within defined range of records to form number of pages, etc
$this->_prep_query();
$query = $this->db->get("comments");
$this->numpages = ceil($query->num_rows / $this->limit);
// if a postid does not exist, then we will set the offset and limit for the query
if ($this->paginate == true) {
$offset = ($this->page * $this->limit) - $this->limit;
$this->db->limit($this->limit, $offset);
}
$this->_prep_query();
$query = $this->db->get("comments");
if ($this->commentid) {
return ($query->row());
}
else {
return ($query->result());
}
}
function save() {
$this->_getPostID();
$dbArray = array(
"author" => $this->author,
"emailaddress" => $this->emailaddress,
"url" => $this->url,
"comment" => $this->comment);
if ($this->commentid) {
$this->db->where("commentid", $this->commentid);
$this->db->update("comments", $dbArray);
}
else {
$dbArray["date"] = time();
$dbArray["postid"] = $this->postid;
$this->db->insert("comments", $dbArray);
}
}
function delete() {
$this->db->where("commentid", $this->commentid);
$this->db->delete("comments");
}
function _getPostID() {
$this->db->select("postid");
$this->db->where("urltitle", $this->urltitle);
$query = $this->db->get("posts");
$result = $query->row();
$this->postid = $result->postid;
}
function _prep_query() {
if ($this->urltitle) {
$this->db->where("urltitle", $this->urltitle);
}
$this->db->select("
comments.commentid,
FROM_UNIXTIME(comments.date, '%m/%d/%Y at %h:%i %p') AS date,
comments.author,
comments.emailaddress,
comments.url,
comments.comment,
posts.urltitle,
posts.title");
$this->db->join("posts", "posts.postid = comments.postid");
$this->db->orderby("date DESC");
}
}
?>
After correct the typo I get this error
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: comment
Filename: models/mdl_comments.php
Line Number: 31
And that line is:
Code:
$clean_comment = $this->htmlpurifier->purify($comment ,$purifier_config);