CodeIgniter Forums
Simple query insert duplicates - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Simple query insert duplicates (/thread-33634.html)



Simple query insert duplicates - El Forum - 09-02-2010

[eluser]JohnnyBravo[/eluser]
Hey everybody,

Do you have any idea why runs this query twice?

maintance_model.php
Code:
function log($name, $message, $type = 'user')
    {
        $entry = array(
            'name' => $name,
            'message' => $message,
            'type' => $type,
            'ip' => $this->input->ip_address(),
            'logdate' => date('Y-m-d H:i:s')
        );

        $this->db->insert('watchdog', $entry);
        
    }

test it
Code:
function test()
    {
        $this->watchdog_model->log('system', $this->lang->line('w_unlock_users'), 'maintance');
    }

It insert two rows in the database, and I really don't know why?

Thx for your help!


Simple query insert duplicates - El Forum - 09-02-2010

[eluser]Martín[/eluser]
That is all your code? maybe you are calling log method in another place or something like that?

Regards!


Simple query insert duplicates - El Forum - 09-02-2010

[eluser]WanWizard[/eluser]
Or have a redirect reloading the page, or a missing image that causes a rewrite request to index.php...

Set your log_threshold to 4, and check your application log. You should see multiple requests there if that is causing it.