Welcome Guest, Not a member yet? Register   Sign In
First Time Using Models
#1

[eluser]Bl4cKWid0w[/eluser]
I'm using models to create a wiki. I get a php syntax error saying that it can't redeclare class Wiki on line 59. Line 59 is empty. I already made sure that all my if statements, etc were closed. Here is my code:
Code:
<?php

class Wiki extends Model {
    
    var $title;
    var $author;
    var $date;
    var $body;
    var $lasteditby;
    var $lastediton;
    var $views;
    var $categoryID;
    
    function wiki(){
        
        parent::Model();
        
    }
    
    function create($title, $author, $date, $body, $lasteditby, $lastediton, $categoryID){
        
        $insert = array(
                        'title' => $title,
                        'author' => $author,
                        'date' => $date,
                        'body' => htmlentities($body),
                        'lasteditby' => $lasteditby,
                        'lastediton' => $lastediton,
                        'categoryID' => $categoryID
                        );
        $query = $this->db->insert('wikis',$insert);
        
    }
    
    function get_new(){
        
        $query = $this->db->query("SELECT * FROM wikis ORDER BY wikiID DESC LIMIT 5");
        if($query->num_rows() == 0){
            echo "<h1>There are no wiki's to display at this time</h1>";
        } else {
             foreach($query->result() as $wiki){
                 echo "<li>".anchor('http://www.unholydesigns.com/technicliche/wiki/article/'.$wiki->wikiID, $wiki->title)."</li>";
             }
        }
        
    }
    
    function get_popular(){
        
        $query = $this->db->query("SELECT * FROM wikiws ORDER BY views");
        if($query->num_rows() == 0){
            echo "<h1>There are no wiki's to display at this time</h1>";
        } else {
            foreach($query->result() as $wiki){
                echo "<li>".anchor('http://www.unholydesigns.com/technicliche/wiki/article/'.$wiki->wikiID, $wiki->title)."</li>";
            }
        }
    }
}
#2

[eluser]gstjohn[/eluser]
Try capitalizing your constructor.

Code:
function Wiki(){
    parent::Model();    
}
#3

[eluser]gstjohn[/eluser]
Double post...sorry!

Do you have a controller named 'Wiki'? That is likely causing the redeclaration.
#4

[eluser]missionsix[/eluser]
[quote author="gstjohn" date="1229144916"]Double post...sorry!

Do you have a controller named 'Wiki'? That is likely causing the redeclaration.[/quote]

it IS whats causing the problem. Hes just looking in the wrong place. Check your controller where you are loading the wiki model, that is where the class declaration collides.
#5

[eluser]Bl4cKWid0w[/eluser]
Yeah, that was it. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB