[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