Welcome Guest, Not a member yet? Register   Sign In
problem creating a model
#1

[eluser]Oblium[/eluser]
I have this model:
Code:
class Elenco_model extends CI_Model {
    
    var $titolo = "";
    var $descrizione = "";
    
    function __construct()
    {
        parent::__construct();
    }
    
    function insert_element($t,$d){
        $dati = array( 'titolo' => $t, 'descrizione' => $d );
        
        $this->db->insert('elenco',$dati);
    }
}

saved in a file called elenco_model.php in model folder

I've also this controller:

Code:
class Blog extends CI_Controller {

    public function index(){
        
        $data['title'] = "Titolo del Blog";
        $data['elements'] = array("elemento1","elemento2","elemento3");
        $this->load->view('blogview',$data);
    }
    
    public function insertdata($titolo,$data){
        
        $this->load->model('Elenco_model');
        $this->Elenco_model->insert_element($titolo,$data);
    }
}

in a file called blog.php in the controller folder.

As i try to call path like "../blog/insertdata/titolo1/descrizione1/" it gives me this error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$db

Filename: core/Model.php

Line Number: 50

Fatal error: Call to a member function insert() on a non-object in C:\xampp\htdocs\ign\application\models\elenco_model.php on line 15

What's wrong in my code?

Thanks


Messages In This Thread
problem creating a model - by El Forum - 04-07-2011, 05:03 AM
problem creating a model - by El Forum - 04-07-2011, 06:25 AM
problem creating a model - by El Forum - 04-07-2011, 07:38 AM
problem creating a model - by El Forum - 04-07-2011, 07:43 AM
problem creating a model - by El Forum - 04-07-2011, 08:01 AM
problem creating a model - by El Forum - 04-07-2011, 10:59 AM
problem creating a model - by El Forum - 04-07-2011, 02:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB