[eluser]Unknown[/eluser]
Hello everyone,
Please help me, I am more confused than the chicken crossing the road.
I have some experience in PHP but I am new to Codeigniter. I went through the tutorials of CI before starting to use it in my project.
I am trying to insert records in the database (MySql) using the db->insert() query.
No matter what I do/change/edit/tweak the records are getting added twice.
I have broken it down to the simplest solution and I am completely stuck with no light at the end of the tunnel.
The Controller
class Page extends CI_Controller{
function __construct(){
parent::__construct();
}
private function init(){
$this->load->model('page_model');
}
public function index(){
echo 'index';
}
public function home(){
$this->init();
$this->page_model->add_user();
}
}
The Model
class Page_model extends CI_Model {
function __construct(){
parent::__construct();
$this->load->database();
}
public function add_user(){
$user = array(
'name' => 'warren'
);
$this->db->insert('users', $user );
}
}
I have tried all the possible solutions I can think of.
Fresh Download
Different Systems (Local and remote server)
Zend Server, Wamp Server, Lighttpd
Options like
$this->db->cache_delete_all();
$this->db->query('insert into ...');
$this->db->insert('users', array('name'=>'warren') );
die() right after the insert statement.
$this->db->save_queries = FALSE;
I have enabled the logger and I see it is outputting twice and I am not sure if this is right.
DEBUG - 2011-08-16 11:12:36 --> Config Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Hooks Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Utf8 Class Initialized
DEBUG - 2011-08-16 11:12:36 --> UTF-8 Support Enabled
DEBUG - 2011-08-16 11:12:36 --> URI Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Router Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Output Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Security Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Input Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Global POST and COOKIE data sanitized
DEBUG - 2011-08-16 11:12:36 --> Language Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Loader Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Controller Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Model Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Model Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Database Driver Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Final output sent to browser
DEBUG - 2011-08-16 11:12:36 --> Total execution time: 0.2564
DEBUG - 2011-08-16 11:12:36 --> Config Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Hooks Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Utf8 Class Initialized
DEBUG - 2011-08-16 11:12:36 --> UTF-8 Support Enabled
DEBUG - 2011-08-16 11:12:36 --> URI Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Router Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Output Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Security Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Input Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Global POST and COOKIE data sanitized
DEBUG - 2011-08-16 11:12:36 --> Language Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Loader Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Controller Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Model Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Model Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Database Driver Class Initialized
DEBUG - 2011-08-16 11:12:36 --> Final output sent to browser
DEBUG - 2011-08-16 11:12:36 --> Total execution time: 0.2533
I searched around and I couldn't find a solution to this silly problem.
I also didn't find many posts with this problem which indicates I am doing something wrong.
I have been stuck for 36 hours trying to find out what I am doing wrong.
If someone can please help me I will be very appreciative.
If this is a silly mistake, I apologize as I am new to CI
Thank you in advance.