Welcome Guest, Not a member yet? Register   Sign In
$this->db->insert creates 3 rows instead of 1. This bug depends from a name of a view (unbelievable but true)
#1

[eluser]PaulBY[/eluser]
Hello. This funny bag has been found by me.
I have:

1) The controller:
Code:
<?php
class Test extends CI_Controller {
    public function one() {
        $this->load->database();
        $this->db->query("INSERT INTO test VALUES ('','10')");
        $this->load->view('site_before_footer');
    }
} ?>
2) The database:
Code:
CREATE TABLE IF NOT EXISTS `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `val` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `val` (`val`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8
3) The view is empty

When I open http://mysite/test/one/ , I see THREE rows added to a database per, instead of 1. There’s must be only 1 row, but there’re 3!! IT’S UNBELIEVABLE! I renamed site_before_footer into site_before , and problem become solved. But when I renamed this into a_b_c, problem appeared anew!! I tried it many times - it’s real magic! It seems like a view can’t have a name like string_string_string.

Guys, please try my code. Does it produce these bugs on your machine ??

I use CodeIgniter 2.1.0


Messages In This Thread
$this->db->insert creates 3 rows instead of 1. This bug depends from a name of a view (unbelievable but true) - by El Forum - 05-07-2012, 03:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB