I have simple model, that needs to inset data to my table. All works fine when i use sql and query but when i try to use insert function i get an error that i need to use set ??
id in my database is auto increment and date is time stamp
class Article extends CI_Model {
private $id;
private $title;
private $text;
private $date;
public function __construct()
{
$this->load->database();
}
public function save_article($title,$text)
{
$this->title=$title;
$this->text=$text;
$this->id='';
$this->load->helper('date');
$this->date=now();
print_r($this);
//"INSERT INTO article VALUES ('','".$title."','".$text."',NOW())")
$this->db->insert('articles',$this);
}
}
Article Object ( [id:Article:private] => [title:Article:private] => rrrrrrrrrrr [text:Article:private] => rrrrrrrrrrrrrrrrrr [date:Article:private] => 1351680951 )
A Database Error Occurred
You must use the "set" method to update an entry.
Filename: C:\Program Files (x86)\EasyPHP-12.1\www\blog\system\database\DB_active_rec.php
Line Number: 1174
iddatabase field is unique, and there is already anidwith the value''.