double Insert into database [solved - it was Firefox] |
[eluser]xpix[/eluser]
Hi, Form some reason the data I submit is entered twice into the database. I tried using a model or just simple code but the behavior is the same. The profiler shows only 1 query and I tried to use a global counter to see how many time the insert function is called. The call happens once I do not remember having this behavior 2 days ago. What could have change. As far as I know the code is ok. Trying to insert through Phpmyadmin does not generate a double insert. Here is my controller Code: class AdminSection extends Controller { Here's the model Code: <?php Thank you
[eluser]TheFuzzy0ne[/eluser]
Have you extended any libraries at all? It's almost as if the controller method is being run twice.
[eluser]xpix[/eluser]
What do you mean by that? I extended the Controller and the Model. I auto load the following: $autoload['libraries'] = array('database','form_validation','session','table'); $autoload['helper'] = array('url','form','security','html'); $autoload['plugin'] = array(); $autoload['config'] = array(); $autoload['language'] = array(); $autoload['model'] = array(); I have no clue why the any of my libraries/model are called twice. Here's more info It seems that the second insert is done after I display the data. So the first time you insert and list everything is OK. But if you look in the database there are 2 items with the sam information. So the second insert happens after the call $data['content'] = $this->Program->list_all(); from the }else if($action == 'add'){ section This is even weirder.
[eluser]Dam1an[/eluser]
Enable logging (level 2+) and then see the order the classes are initialised in, might give a clue of what happens twice
[eluser]xpix[/eluser]
Could you be more specific on enabling logging. Never used it before. Thx
[eluser]Dam1an[/eluser]
In config.php, there's a variable 'log_threashold', set this to the appropriate value (I use 4 during development) The logs will be default be written to the log folder in the CI core (make sure its writable) You will also need to log a few messages using log_message in you're own libraries/models/controller so you can follow the flow between CI stuff and yours
[eluser]xpix[/eluser]
Thx guys for everything. After enabling the logging I could clearly see that the page was loaded twice. After restating firefox everything was ok. ![]()
|
Welcome Guest, Not a member yet? Register Sign In |