Welcome Guest, Not a member yet? Register   Sign In
Problem with Model
#1

[eluser]staar2[/eluser]
I just started testing the CI and i have problems using models:

error: An Error Was Encountered
Unable to locate the model you have specified: getdata

blog.php
Code:
<?php

class Blog extends Controller {

    public function __construct()
    {    
        parent::Controller();
    }

    public function index()
    {
        //$this->load->database();
        $this->load->model('GetData');
        $data['data'] = $this->GetData->getName();
        
        if ($this->input->post('saada')) {
            echo 'Olemas';
        }

        $this->load->view('blogview', $data);
    }

    public function name($id, $name)
    {
        echo "Id: ". $id ."<br />";
        echo "Nimi ". $name ."<br />";
    }
}

?&gt;

GetData.php
Code:
&lt;?php

class GetData extends Model {
    
    public function __construct()
    {
        parent::Model();
        
    }

    public function getName()
    {
        $this->load->database();
        $query = $this->db->query('SELECT name FROM inimesed');

        return $query->result_array();
        
    }
}

?&gt;
#2

[eluser]maadmac[/eluser]
[quote author="staar2" date="1195940412"]
GetData.php
Code:
&lt;?php

class GetData extends Model {
    
    public function __construct()
    {
        parent::Model();
        
    }
[/quote]

This is just a stab in the dark, since at a glance I don't see anything wrong with your code, but try removing the "public" keyword from your constructor, so that it just reads "function __construct()". I seem to recall CI having problems -- in models especially -- with PHP5 aspects like that, since they built it to be backward compatible with v4...
#3

[eluser]staar2[/eluser]
didn't work i removed public but still dosen't work. I don't see there some code mistakes, so is there possible to change models folder location ?
And i use linux.
#4

[eluser]Chris Newton[/eluser]
Shouldn't your model name be Getdata and the filename be set at getdata.php ?

I thought CI had a thing for capitalization

http://ellislab.com/codeigniter/user-gui...odels.html
#5

[eluser]staar2[/eluser]
It works ! Ty pro i thought there is something wrong with names.
#6

[eluser]maadmac[/eluser]
[quote author="mahuti" date="1195947300"]Shouldn't your model name be Getdata and the filename be set at getdata.php ?

I thought CI had a thing for capitalization

http://ellislab.com/codeigniter/user-gui...odels.html[/quote]

Good call. Have to remember: lowercase file names, upper case constructors.




Theme © iAndrew 2016 - Forum software by © MyBB